From 4da9bcd7936f899c69c57a0e5a0e6bde853593ec Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Thu, 15 Jun 2023 12:29:24 -0400 Subject: [PATCH] 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 8be9830..1abb1ee 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 9491554..2997215 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; } -- 2.44.1