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/login.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/login.tsx')
-rw-r--r-- | ui/src/components/login.tsx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index c8de6c70..53b7a22f 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -7,6 +7,7 @@ import { LoginResponse, UserOperation, PasswordResetForm, + GetSiteResponse, } from '../interfaces'; import { WebSocketService, UserService } from '../services'; import { msgOp, validEmail } from '../utils'; @@ -18,6 +19,7 @@ interface State { registerForm: RegisterForm; loginLoading: boolean; registerLoading: boolean; + enable_nsfw: boolean; } export class Login extends Component<any, State> { @@ -37,6 +39,7 @@ export class Login extends Component<any, State> { }, loginLoading: false, registerLoading: false, + enable_nsfw: undefined, }; constructor(props: any, context: any) { @@ -58,18 +61,14 @@ export class Login extends Component<any, State> { err => console.error(err), () => console.log('complete') ); + + WebSocketService.Instance.getSite(); } componentWillUnmount() { this.subscription.unsubscribe(); } - componentDidMount() { - document.title = `${i18n.t('login')} - ${ - WebSocketService.Instance.site.name - }`; - } - render() { return ( <div class="container"> @@ -205,7 +204,7 @@ export class Login extends Component<any, State> { /> </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"> @@ -322,6 +321,13 @@ export class Login extends Component<any, State> { this.props.history.push('/communities'); } else if (op == UserOperation.PasswordReset) { alert(i18n.t('reset_password_mail_sent')); + } else if (op == UserOperation.GetSite) { + let res: GetSiteResponse = msg; + this.state.enable_nsfw = res.site.enable_nsfw; + this.setState(this.state); + document.title = `${i18n.t('login')} - ${ + WebSocketService.Instance.site.name + }`; } } } |