getDataTypeFromProps,
getPageFromProps,
getSortTypeFromProps,
+ isPostBlocked,
notifyPost,
+ nsfwCheck,
postToCommentSortType,
relTags,
restoreScrollPosition,
get documentTitle(): string {
return this.state.communityRes.match({
some: res =>
- this.state.siteRes.site_view.match({
- some: siteView =>
- `${res.community_view.community.title} - ${siteView.site.name}`,
- none: "",
- }),
+ `${res.community_view.community.title} - ${this.state.siteRes.site_view.site.name}`,
none: "",
});
}
render() {
+ // For some reason, this returns an empty vec if it matches the site langs
+ let communityLangs = this.state.communityRes.map(r => {
+ let langs = r.discussion_languages;
+ if (langs.length == 0) {
+ return this.state.siteRes.all_languages.map(l => l.id);
+ } else {
+ return langs;
+ }
+ });
+
return (
- <div className="container">
+ <div className="container-lg">
{this.state.communityLoading ? (
<h5>
<Spinner large />
admins={this.state.siteRes.admins}
online={res.online}
enableNsfw={enableNsfw(this.state.siteRes)}
+ editable
+ allLanguages={this.state.siteRes.all_languages}
+ siteLanguages={
+ this.state.siteRes.discussion_languages
+ }
+ communityLanguages={communityLangs}
/>
{!res.community_view.community.local &&
res.site.match({
admins={this.state.siteRes.admins}
online={res.online}
enableNsfw={enableNsfw(this.state.siteRes)}
+ editable
+ allLanguages={this.state.siteRes.all_languages}
+ siteLanguages={this.state.siteRes.discussion_languages}
+ communityLanguages={communityLangs}
/>
{!res.community_view.community.local &&
res.site.match({
removeDuplicates
enableDownvotes={enableDownvotes(this.state.siteRes)}
enableNsfw={enableNsfw(this.state.siteRes)}
+ allLanguages={this.state.siteRes.all_languages}
+ siteLanguages={this.state.siteRes.discussion_languages}
/>
)
) : this.state.commentsLoading ? (
moderators={this.state.communityRes.map(r => r.moderators)}
admins={Some(this.state.siteRes.admins)}
maxCommentsShown={None}
+ allLanguages={this.state.siteRes.all_languages}
+ siteLanguages={this.state.siteRes.discussion_languages}
/>
);
}
) {
let data = wsJsonToRes<CommunityResponse>(msg, CommunityResponse);
this.state.communityRes.match({
- some: res => (res.community_view = data.community_view),
+ some: res => {
+ res.community_view = data.community_view;
+ res.discussion_languages = data.discussion_languages;
+ },
none: void 0,
});
this.setState(this.state);
op == UserOperation.DeletePost ||
op == UserOperation.RemovePost ||
op == UserOperation.LockPost ||
- op == UserOperation.StickyPost ||
+ op == UserOperation.FeaturePost ||
op == UserOperation.SavePost
) {
let data = wsJsonToRes<PostResponse>(msg, PostResponse);
this.setState(this.state);
} else if (op == UserOperation.CreatePost) {
let data = wsJsonToRes<PostResponse>(msg, PostResponse);
- this.state.posts.unshift(data.post_view);
+
+ let showPostNotifs = UserService.Instance.myUserInfo
+ .map(m => m.local_user_view.local_user.show_new_post_notifs)
+ .unwrapOr(false);
+
+ // Only push these if you're on the first page, you pass the nsfw check, and it isn't blocked
+ //
if (
- UserService.Instance.myUserInfo
- .map(m => m.local_user_view.local_user.show_new_post_notifs)
- .unwrapOr(false)
+ this.state.page == 1 &&
+ nsfwCheck(data.post_view) &&
+ !isPostBlocked(data.post_view)
) {
- notifyPost(data.post_view, this.context.router);
+ this.state.posts.unshift(data.post_view);
+ if (showPostNotifs) {
+ notifyPost(data.post_view, this.context.router);
+ }
+ this.setState(this.state);
}
- this.setState(this.state);
} else if (op == UserOperation.CreatePostLike) {
let data = wsJsonToRes<PostResponse>(msg, PostResponse);
createPostLikeFindRes(data.post_view, this.state.posts);