|
|
@ -18,7 +18,6 @@ import {
|
|
|
|
BanUserResponse,
|
|
|
|
BanUserResponse,
|
|
|
|
AddModToCommunityResponse,
|
|
|
|
AddModToCommunityResponse,
|
|
|
|
AddAdminResponse,
|
|
|
|
AddAdminResponse,
|
|
|
|
UserView,
|
|
|
|
|
|
|
|
SearchType,
|
|
|
|
SearchType,
|
|
|
|
SortType,
|
|
|
|
SortType,
|
|
|
|
SearchForm,
|
|
|
|
SearchForm,
|
|
|
@ -52,12 +51,12 @@ interface PostState {
|
|
|
|
commentSort: CommentSortType;
|
|
|
|
commentSort: CommentSortType;
|
|
|
|
community: Community;
|
|
|
|
community: Community;
|
|
|
|
moderators: Array<CommunityUser>;
|
|
|
|
moderators: Array<CommunityUser>;
|
|
|
|
admins: Array<UserView>;
|
|
|
|
|
|
|
|
online: number;
|
|
|
|
online: number;
|
|
|
|
scrolled?: boolean;
|
|
|
|
scrolled?: boolean;
|
|
|
|
scrolled_comment_id?: number;
|
|
|
|
scrolled_comment_id?: number;
|
|
|
|
loading: boolean;
|
|
|
|
loading: boolean;
|
|
|
|
crossPosts: Array<PostI>;
|
|
|
|
crossPosts: Array<PostI>;
|
|
|
|
|
|
|
|
siteRes: GetSiteResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export class Post extends Component<any, PostState> {
|
|
|
|
export class Post extends Component<any, PostState> {
|
|
|
@ -68,11 +67,29 @@ export class Post extends Component<any, PostState> {
|
|
|
|
commentSort: CommentSortType.Hot,
|
|
|
|
commentSort: CommentSortType.Hot,
|
|
|
|
community: null,
|
|
|
|
community: null,
|
|
|
|
moderators: [],
|
|
|
|
moderators: [],
|
|
|
|
admins: [],
|
|
|
|
|
|
|
|
online: null,
|
|
|
|
online: null,
|
|
|
|
scrolled: false,
|
|
|
|
scrolled: false,
|
|
|
|
loading: true,
|
|
|
|
loading: true,
|
|
|
|
crossPosts: [],
|
|
|
|
crossPosts: [],
|
|
|
|
|
|
|
|
siteRes: {
|
|
|
|
|
|
|
|
admins: [],
|
|
|
|
|
|
|
|
banned: [],
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
online: null,
|
|
|
|
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: any, context: any) {
|
|
|
|
constructor(props: any, context: any) {
|
|
|
@ -97,6 +114,7 @@ export class Post extends Component<any, PostState> {
|
|
|
|
id: postId,
|
|
|
|
id: postId,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
WebSocketService.Instance.getPost(form);
|
|
|
|
WebSocketService.Instance.getPost(form);
|
|
|
|
|
|
|
|
WebSocketService.Instance.getSite();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
componentWillUnmount() {
|
|
|
@ -180,7 +198,9 @@ export class Post extends Component<any, PostState> {
|
|
|
|
showBody
|
|
|
|
showBody
|
|
|
|
showCommunity
|
|
|
|
showCommunity
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
admins={this.state.admins}
|
|
|
|
admins={this.state.siteRes.admins}
|
|
|
|
|
|
|
|
enableDownvotes={this.state.siteRes.site.enable_downvotes}
|
|
|
|
|
|
|
|
enableNsfw={this.state.siteRes.site.enable_nsfw}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<div className="mb-2" />
|
|
|
|
<div className="mb-2" />
|
|
|
|
<CommentForm
|
|
|
|
<CommentForm
|
|
|
@ -269,9 +289,10 @@ export class Post extends Component<any, PostState> {
|
|
|
|
noIndent
|
|
|
|
noIndent
|
|
|
|
locked={this.state.post.locked}
|
|
|
|
locked={this.state.post.locked}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
admins={this.state.admins}
|
|
|
|
admins={this.state.siteRes.admins}
|
|
|
|
postCreatorId={this.state.post.creator_id}
|
|
|
|
postCreatorId={this.state.post.creator_id}
|
|
|
|
showContext
|
|
|
|
showContext
|
|
|
|
|
|
|
|
enableDownvotes={this.state.siteRes.site.enable_downvotes}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -284,8 +305,9 @@ export class Post extends Component<any, PostState> {
|
|
|
|
<Sidebar
|
|
|
|
<Sidebar
|
|
|
|
community={this.state.community}
|
|
|
|
community={this.state.community}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
admins={this.state.admins}
|
|
|
|
admins={this.state.siteRes.admins}
|
|
|
|
online={this.state.online}
|
|
|
|
online={this.state.online}
|
|
|
|
|
|
|
|
enableNsfw={this.state.siteRes.site.enable_nsfw}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -336,9 +358,10 @@ export class Post extends Component<any, PostState> {
|
|
|
|
nodes={nodes}
|
|
|
|
nodes={nodes}
|
|
|
|
locked={this.state.post.locked}
|
|
|
|
locked={this.state.post.locked}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
moderators={this.state.moderators}
|
|
|
|
admins={this.state.admins}
|
|
|
|
admins={this.state.siteRes.admins}
|
|
|
|
postCreatorId={this.state.post.creator_id}
|
|
|
|
postCreatorId={this.state.post.creator_id}
|
|
|
|
sort={this.state.commentSort}
|
|
|
|
sort={this.state.commentSort}
|
|
|
|
|
|
|
|
enableDownvotes={this.state.siteRes.site.enable_downvotes}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -360,10 +383,10 @@ export class Post extends Component<any, PostState> {
|
|
|
|
this.state.comments = data.comments;
|
|
|
|
this.state.comments = data.comments;
|
|
|
|
this.state.community = data.community;
|
|
|
|
this.state.community = data.community;
|
|
|
|
this.state.moderators = data.moderators;
|
|
|
|
this.state.moderators = data.moderators;
|
|
|
|
this.state.admins = data.admins;
|
|
|
|
this.state.siteRes.admins = data.admins;
|
|
|
|
this.state.online = data.online;
|
|
|
|
this.state.online = data.online;
|
|
|
|
this.state.loading = false;
|
|
|
|
this.state.loading = false;
|
|
|
|
document.title = `${this.state.post.name} - ${WebSocketService.Instance.site.name}`;
|
|
|
|
document.title = `${this.state.post.name} - ${this.state.siteRes.site.name}`;
|
|
|
|
|
|
|
|
|
|
|
|
// Get cross-posts
|
|
|
|
// Get cross-posts
|
|
|
|
if (this.state.post.url) {
|
|
|
|
if (this.state.post.url) {
|
|
|
@ -450,7 +473,7 @@ export class Post extends Component<any, PostState> {
|
|
|
|
this.setState(this.state);
|
|
|
|
this.setState(this.state);
|
|
|
|
} else if (res.op == UserOperation.AddAdmin) {
|
|
|
|
} else if (res.op == UserOperation.AddAdmin) {
|
|
|
|
let data = res.data as AddAdminResponse;
|
|
|
|
let data = res.data as AddAdminResponse;
|
|
|
|
this.state.admins = data.admins;
|
|
|
|
this.state.siteRes.admins = data.admins;
|
|
|
|
this.setState(this.state);
|
|
|
|
this.setState(this.state);
|
|
|
|
} else if (res.op == UserOperation.Search) {
|
|
|
|
} else if (res.op == UserOperation.Search) {
|
|
|
|
let data = res.data as SearchResponse;
|
|
|
|
let data = res.data as SearchResponse;
|
|
|
@ -461,15 +484,18 @@ export class Post extends Component<any, PostState> {
|
|
|
|
this.state.post.duplicates = this.state.crossPosts;
|
|
|
|
this.state.post.duplicates = this.state.crossPosts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setState(this.state);
|
|
|
|
this.setState(this.state);
|
|
|
|
} else if (res.op == UserOperation.TransferSite) {
|
|
|
|
} else if (
|
|
|
|
|
|
|
|
res.op == UserOperation.TransferSite ||
|
|
|
|
|
|
|
|
res.op == UserOperation.GetSite
|
|
|
|
|
|
|
|
) {
|
|
|
|
let data = res.data as GetSiteResponse;
|
|
|
|
let data = res.data as GetSiteResponse;
|
|
|
|
this.state.admins = data.admins;
|
|
|
|
this.state.siteRes = data;
|
|
|
|
this.setState(this.state);
|
|
|
|
this.setState(this.state);
|
|
|
|
} else if (res.op == UserOperation.TransferCommunity) {
|
|
|
|
} else if (res.op == UserOperation.TransferCommunity) {
|
|
|
|
let data = res.data as GetCommunityResponse;
|
|
|
|
let data = res.data as GetCommunityResponse;
|
|
|
|
this.state.community = data.community;
|
|
|
|
this.state.community = data.community;
|
|
|
|
this.state.moderators = data.moderators;
|
|
|
|
this.state.moderators = data.moderators;
|
|
|
|
this.state.admins = data.admins;
|
|
|
|
this.state.siteRes.admins = data.admins;
|
|
|
|
this.setState(this.state);
|
|
|
|
this.setState(this.state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|