diff options
author | Dessalines <tyhou13@gmx.com> | 2020-07-08 01:02:14 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-07-08 01:02:14 -0400 |
commit | cd4e0ab3c2cfd615e4771fb9181a31ce237b5ceb (patch) | |
tree | 699dd63cd3ad7601e49a1173884506e3638ae37a /ui/src/components/community.tsx | |
parent | 8fda7d00d5ec9e415b44aa10cff3c4d735563a20 (diff) |
HTML title bugs.
- Fixing HTML titles for some pages. Fixes #801
- Removing WebSocketService.Instance.site, fetching site on demand now.
Diffstat (limited to 'ui/src/components/community.tsx')
-rw-r--r-- | ui/src/components/community.tsx | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index c193532b..ff50c3dc 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -23,6 +23,8 @@ import { GetCommentsResponse, CommentResponse, WebSocketJsonResponse, + GetSiteResponse, + Site, } from '../interfaces'; import { WebSocketService } from '../services'; import { PostListings } from './post-listings'; @@ -60,6 +62,7 @@ interface State { dataType: DataType; sort: SortType; page: number; + site: Site; } export class Community extends Component<any, State> { @@ -97,6 +100,20 @@ export class Community extends Component<any, State> { dataType: getDataTypeFromProps(this.props), sort: getSortTypeFromProps(this.props), page: getPageFromProps(this.props), + site: { + id: undefined, + name: undefined, + creator_id: undefined, + published: undefined, + creator_name: undefined, + number_of_users: undefined, + number_of_posts: undefined, + number_of_comments: undefined, + number_of_communities: undefined, + enable_downvotes: undefined, + open_registration: undefined, + enable_nsfw: undefined, + }, }; constructor(props: any, context: any) { @@ -119,6 +136,7 @@ export class Community extends Component<any, State> { name: this.state.communityName ? this.state.communityName : null, }; WebSocketService.Instance.getCommunity(form); + WebSocketService.Instance.getSite(); } componentWillUnmount() { @@ -174,6 +192,7 @@ export class Community extends Component<any, State> { moderators={this.state.moderators} admins={this.state.admins} online={this.state.online} + enableNsfw={this.state.site.enable_nsfw} /> </div> </div> @@ -188,6 +207,8 @@ export class Community extends Component<any, State> { posts={this.state.posts} removeDuplicates sort={this.state.sort} + enableDownvotes={this.state.site.enable_downvotes} + enableNsfw={this.state.site.enable_nsfw} /> ) : ( <CommentNodes @@ -195,6 +216,7 @@ export class Community extends Component<any, State> { noIndent sortType={this.state.sort} showContext + enableDownvotes={this.state.site.enable_downvotes} /> ); } @@ -331,7 +353,7 @@ export class Community extends Component<any, State> { this.state.moderators = data.moderators; this.state.admins = data.admins; this.state.online = data.online; - document.title = `/c/${this.state.community.name} - ${WebSocketService.Instance.site.name}`; + document.title = `/c/${this.state.community.name} - ${this.state.site.name}`; this.setState(this.state); this.fetchData(); } else if (res.op == UserOperation.EditCommunity) { @@ -399,6 +421,10 @@ export class Community extends Component<any, State> { let data = res.data as CommentResponse; createCommentLikeRes(data, this.state.comments); this.setState(this.state); + } else if (res.op == UserOperation.GetSite) { + let data = res.data as GetSiteResponse; + this.state.site = data.site; + this.setState(this.state); } } } |