]> Untitled Git - lemmy-ui.git/commitdiff
go back if last history action was push, fix bug preventing navigation to / working...
authorAlec Armbruster <alectrocute@gmail.com>
Thu, 15 Jun 2023 16:29:24 +0000 (12:29 -0400)
committerAlec Armbruster <alectrocute@gmail.com>
Thu, 15 Jun 2023 16:29:24 +0000 (12:29 -0400)
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..29972151508f1479221750e5f956d40141487d54 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.push("/");
 
           break;
         }