]> Untitled Git - lemmy-ui.git/commitdiff
Merge pull request #1309 from alectrocute/go-back-after-login
authorSleeplessOne1917 <abias1122@gmail.com>
Thu, 15 Jun 2023 17:23:20 +0000 (17:23 +0000)
committerGitHub <noreply@github.com>
Thu, 15 Jun 2023 17:23:20 +0000 (17:23 +0000)
Go back to previous page after login

src/shared/components/home/home.tsx
src/shared/components/home/login.tsx

index 8be983042a5ce584988bb282d928656678ddfeb0..1abb1ee329f391ab52e93e1c33d389e173ddf834 100644 (file)
@@ -244,9 +244,10 @@ export class Home extends Component<any, HomeState> {
   }
 
   async componentDidMount() {
-    if (!this.state.isIsomorphic) {
+    if (!this.state.isIsomorphic || !this.isoData.routeData.length) {
       await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
     }
+
     setupTippy();
   }
 
@@ -456,7 +457,7 @@ export class Home extends Component<any, HomeState> {
   }
 
   trendingCommunities(isMobile = false) {
-    switch (this.state.trendingCommunitiesRes.state) {
+    switch (this.state.trendingCommunitiesRes?.state) {
       case "loading":
         return (
           <h5>
@@ -573,7 +574,7 @@ export class Home extends Component<any, HomeState> {
     const siteRes = this.state.siteRes;
 
     if (dataType === DataType.Post) {
-      switch (this.state.postsRes.state) {
+      switch (this.state.postsRes?.state) {
         case "loading":
           return (
             <h5>
index 949155424d8ee933136ed84d76f6307a06b90db9..381c13bb0ce05dac89f5b3068009f5c59940c0d7 100644 (file)
@@ -186,7 +186,9 @@ export class Login extends Component<any, State> {
             UserService.Instance.myUserInfo = site.data.my_user;
           }
 
-          i.props.history.replace("/");
+          i.props.history.action === "PUSH"
+            ? i.props.history.back()
+            : i.props.history.replace("/");
 
           break;
         }