summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-form.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-03 13:52:21 -0500
committerDessalines <tyhou13@gmx.com>2020-01-03 13:52:21 -0500
commit747a8f5b96b10f56f14d7dad30764084e69d8cab (patch)
tree74b1f5ad8d967540239effb8c6bbfe992539a3aa /ui/src/components/post-form.tsx
parentc252785632f91d5c819a723d6cfbbf0512e40c06 (diff)
Fixing create_post, create_community, and login pages.
- Includes fetching the site for `enable_nsfw` info. Fixes #400
Diffstat (limited to 'ui/src/components/post-form.tsx')
-rw-r--r--ui/src/components/post-form.tsx10
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx
index ef639c9d..7964a3ff 100644
--- a/ui/src/components/post-form.tsx
+++ b/ui/src/components/post-form.tsx
@@ -15,6 +15,7 @@ import {
SearchForm,
SearchType,
SearchResponse,
+ GetSiteResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import {
@@ -49,6 +50,7 @@ interface PostFormState {
suggestedTitle: string;
suggestedPosts: Array<Post>;
crossPosts: Array<Post>;
+ enable_nsfw: boolean;
}
export class PostForm extends Component<PostFormProps, PostFormState> {
@@ -70,6 +72,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
suggestedTitle: undefined,
suggestedPosts: [],
crossPosts: [],
+ enable_nsfw: undefined,
};
constructor(props: any, context: any) {
@@ -124,6 +127,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
};
WebSocketService.Instance.listCommunities(listCommunitiesForm);
+ WebSocketService.Instance.getSite();
}
componentDidMount() {
@@ -287,7 +291,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
</div>
</div>
)}
- {WebSocketService.Instance.site.enable_nsfw && (
+ {this.state.enable_nsfw && (
<div class="form-group row">
<div class="col-sm-10">
<div class="form-check">
@@ -498,6 +502,10 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
this.state.crossPosts = res.posts;
}
this.setState(this.state);
+ } else if (op == UserOperation.GetSite) {
+ let res: GetSiteResponse = msg;
+ this.state.enable_nsfw = res.site.enable_nsfw;
+ this.setState(this.state);
}
}
}