mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-24 23:31:30 +00:00
Get it working for non-setup site.
This commit is contained in:
parent
33088ea760
commit
6a3dc3264f
|
@ -152,6 +152,11 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
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 });
|
WebSocketService.Instance.communityJoin({ community_id: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +245,9 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
get documentTitle(): string {
|
get documentTitle(): string {
|
||||||
return `${this.state.siteRes.site.name}`;
|
return `${
|
||||||
|
this.state.siteRes.site ? this.state.siteRes.site.name : 'Lemmy'
|
||||||
|
}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -250,12 +257,14 @@ export class Main extends Component<any, MainState> {
|
||||||
title={this.documentTitle}
|
title={this.documentTitle}
|
||||||
path={this.context.router.route.match.url}
|
path={this.context.router.route.match.url}
|
||||||
/>
|
/>
|
||||||
<div class="row">
|
{this.state.siteRes.site && (
|
||||||
<main role="main" class="col-12 col-md-8">
|
<div class="row">
|
||||||
{this.posts()}
|
<main role="main" class="col-12 col-md-8">
|
||||||
</main>
|
{this.posts()}
|
||||||
<aside class="col-12 col-md-4">{this.mySidebar()}</aside>
|
</main>
|
||||||
</div>
|
<aside class="col-12 col-md-4">{this.mySidebar()}</aside>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -394,7 +403,7 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
siteName() {
|
siteName() {
|
||||||
return <h5 class="mb-0">{`${this.state.siteRes.site.name}`}</h5>;
|
return <h5 class="mb-0">{`${this.documentTitle}`}</h5>;
|
||||||
}
|
}
|
||||||
|
|
||||||
admins() {
|
admins() {
|
||||||
|
@ -719,18 +728,6 @@ export class Main extends Component<any, MainState> {
|
||||||
let data = res.data as ListCommunitiesResponse;
|
let data = res.data as ListCommunitiesResponse;
|
||||||
this.state.trendingCommunities = data.communities;
|
this.state.trendingCommunities = data.communities;
|
||||||
this.setState(this.state);
|
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) {
|
} else if (res.op == UserOperation.EditSite) {
|
||||||
let data = res.data as SiteResponse;
|
let data = res.data as SiteResponse;
|
||||||
this.state.siteRes.site = data.site;
|
this.state.siteRes.site = data.site;
|
||||||
|
|
|
@ -205,7 +205,7 @@ export class Setup extends Component<any, State> {
|
||||||
UserService.Instance.login(data);
|
UserService.Instance.login(data);
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (res.op == UserOperation.CreateSite) {
|
} else if (res.op == UserOperation.CreateSite) {
|
||||||
this.props.history.push('/');
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue