From: Dessalines Date: Tue, 15 Sep 2020 16:44:46 +0000 (-0500) Subject: Get it working for non-setup site. X-Git-Url: http://these/git/%22https:/www.exeterceilidhs.net/%22%7B%7D/README.zh.hans.md?a=commitdiff_plain;h=6a3dc3264fb023f844cde74d7774d2fb7b058505;p=lemmy-ui.git Get it working for non-setup site. --- diff --git a/src/shared/components/main.tsx b/src/shared/components/main.tsx index 33d79ec..54bb66b 100644 --- a/src/shared/components/main.tsx +++ b/src/shared/components/main.tsx @@ -152,6 +152,11 @@ export class Main extends Component { } componentDidMount() { + // This means it hasn't been set up yet + if (!this.state.siteRes.site) { + this.context.router.history.push('/setup'); + } + WebSocketService.Instance.communityJoin({ community_id: 0 }); } @@ -240,7 +245,9 @@ export class Main extends Component { } get documentTitle(): string { - return `${this.state.siteRes.site.name}`; + return `${ + this.state.siteRes.site ? this.state.siteRes.site.name : 'Lemmy' + }`; } render() { @@ -250,12 +257,14 @@ export class Main extends Component { title={this.documentTitle} path={this.context.router.route.match.url} /> -
-
- {this.posts()} -
- -
+ {this.state.siteRes.site && ( +
+
+ {this.posts()} +
+ +
+ )} ); } @@ -394,7 +403,7 @@ export class Main extends Component { } siteName() { - return
{`${this.state.siteRes.site.name}`}
; + return
{`${this.documentTitle}`}
; } admins() { @@ -719,18 +728,6 @@ export class Main extends Component { let data = res.data as ListCommunitiesResponse; this.state.trendingCommunities = data.communities; this.setState(this.state); - } else if (res.op == UserOperation.GetSite) { - let data = res.data as GetSiteResponse; - - // This means it hasn't been set up yet - if (!data.site) { - this.context.router.history.push('/setup'); - } - this.state.siteRes.admins = data.admins; - this.state.siteRes.site = data.site; - this.state.siteRes.banned = data.banned; - this.state.siteRes.online = data.online; - this.setState(this.state); } else if (res.op == UserOperation.EditSite) { let data = res.data as SiteResponse; this.state.siteRes.site = data.site; diff --git a/src/shared/components/setup.tsx b/src/shared/components/setup.tsx index 6360ec5..33fa443 100644 --- a/src/shared/components/setup.tsx +++ b/src/shared/components/setup.tsx @@ -205,7 +205,7 @@ export class Setup extends Component { UserService.Instance.login(data); this.setState(this.state); } else if (res.op == UserOperation.CreateSite) { - this.props.history.push('/'); + window.location.href = '/'; } } }