diff options
author | Dessalines <tyhou13@gmx.com> | 2020-01-23 19:17:42 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-01-23 19:17:42 -0500 |
commit | ac1d5f2b86b0816cc9b5794dc6c38a38365ed839 (patch) | |
tree | bedaab04ca797113990e5702cad36f5e34e9e6e8 /ui/src/components/setup.tsx | |
parent | 39d1fb4450cb418d9c11b31ea99484c2a177fab6 (diff) | |
parent | b45c83682c187737b092080e83ba741c39cfa695 (diff) |
Done merging http-api and private_message
Diffstat (limited to 'ui/src/components/setup.tsx')
-rw-r--r-- | ui/src/components/setup.tsx | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/ui/src/components/setup.tsx b/ui/src/components/setup.tsx index d06a9a58..26475a38 100644 --- a/ui/src/components/setup.tsx +++ b/ui/src/components/setup.tsx @@ -1,9 +1,14 @@ import { Component, linkEvent } from 'inferno'; import { Subscription } from 'rxjs'; import { retryWhen, delay, take } from 'rxjs/operators'; -import { RegisterForm, LoginResponse, UserOperation } from '../interfaces'; +import { + RegisterForm, + LoginResponse, + UserOperation, + WebSocketJsonResponse, +} from '../interfaces'; import { WebSocketService, UserService } from '../services'; -import { msgOp, toast } from '../utils'; +import { wsJsonToRes, toast } from '../utils'; import { SiteForm } from './site-form'; import { i18n } from '../i18next'; import { T } from 'inferno-i18next'; @@ -181,21 +186,20 @@ export class Setup extends Component<any, State> { i.setState(i.state); } - parseMessage(msg: any) { - let op: UserOperation = msgOp(msg); - if (msg.error) { + parseMessage(msg: WebSocketJsonResponse) { + let res = wsJsonToRes(msg); + if (res.error) { toast(i18n.t(msg.error), 'danger'); this.state.userLoading = false; this.setState(this.state); return; - } else if (op == UserOperation.Register) { + } else if (res.op == UserOperation.Register) { + let data = res.data as LoginResponse; this.state.userLoading = false; this.state.doneRegisteringUser = true; - let res: LoginResponse = msg; - UserService.Instance.login(res); - console.log(res); + UserService.Instance.login(data); this.setState(this.state); - } else if (op == UserOperation.CreateSite) { + } else if (res.op == UserOperation.CreateSite) { this.props.history.push('/'); } } |