diff options
author | Dessalines <tyhou13@gmx.com> | 2020-01-03 13:52:21 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-01-03 13:52:21 -0500 |
commit | 747a8f5b96b10f56f14d7dad30764084e69d8cab (patch) | |
tree | 74b1f5ad8d967540239effb8c6bbfe992539a3aa /ui/src/components/community-form.tsx | |
parent | c252785632f91d5c819a723d6cfbbf0512e40c06 (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/community-form.tsx')
-rw-r--r-- | ui/src/components/community-form.tsx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx index d5efb432..2085da28 100644 --- a/ui/src/components/community-form.tsx +++ b/ui/src/components/community-form.tsx @@ -7,6 +7,7 @@ import { Category, ListCategoriesResponse, CommunityResponse, + GetSiteResponse, } from '../interfaces'; import { WebSocketService } from '../services'; import { msgOp, capitalizeFirstLetter } from '../utils'; @@ -27,6 +28,7 @@ interface CommunityFormState { communityForm: CommunityFormI; categories: Array<Category>; loading: boolean; + enable_nsfw: boolean; } export class CommunityForm extends Component< @@ -44,6 +46,7 @@ export class CommunityForm extends Component< }, categories: [], loading: false, + enable_nsfw: null, }; constructor(props: any, context: any) { @@ -79,6 +82,7 @@ export class CommunityForm extends Component< ); WebSocketService.Instance.listCategories(); + WebSocketService.Instance.getSite(); } componentDidMount() { @@ -157,7 +161,7 @@ export class CommunityForm extends Component< </div> </div> - {WebSocketService.Instance.site.enable_nsfw && ( + {this.state.enable_nsfw && ( <div class="form-group row"> <div class="col-12"> <div class="form-check"> @@ -267,6 +271,10 @@ export class CommunityForm extends Component< let res: CommunityResponse = msg; this.state.loading = false; this.props.onEdit(res.community); + } else if (op == UserOperation.GetSite) { + let res: GetSiteResponse = msg; + this.state.enable_nsfw = res.site.enable_nsfw; + this.setState(this.state); } } } |