From 4da9bcd7936f899c69c57a0e5a0e6bde853593ec Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Thu, 15 Jun 2023 12:29:24 -0400 Subject: [PATCH 1/2] go back if last history action was push, fix bug preventing navigation to / working from login --- src/shared/components/home/home.tsx | 7 ++++--- src/shared/components/home/login.tsx | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index 8be98304..1abb1ee3 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -244,9 +244,10 @@ export class Home extends Component { } 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 { } trendingCommunities(isMobile = false) { - switch (this.state.trendingCommunitiesRes.state) { + switch (this.state.trendingCommunitiesRes?.state) { case "loading": return (
@@ -573,7 +574,7 @@ export class Home extends Component { const siteRes = this.state.siteRes; if (dataType === DataType.Post) { - switch (this.state.postsRes.state) { + switch (this.state.postsRes?.state) { case "loading": return (
diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 94915542..29972151 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -186,7 +186,9 @@ export class Login extends Component { 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; } From 114ad262c3fd0da01fca98a4ea8fe094b953beb9 Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Thu, 15 Jun 2023 12:38:42 -0400 Subject: [PATCH 2/2] use .replace() instead --- src/shared/components/home/login.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 29972151..381c13bb 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -188,7 +188,7 @@ export class Login extends Component { i.props.history.action === "PUSH" ? i.props.history.back() - : i.props.history.push("/"); + : i.props.history.replace("/"); break; }