summaryrefslogtreecommitdiffstats
path: root/ui/src/components/password_change.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-18 23:54:10 -0500
committerDessalines <tyhou13@gmx.com>2020-01-18 23:54:10 -0500
commita044718066623f19d51196d444bd199c1231cebe (patch)
treecbffb18d826df1330ce2b7f1a814205ba45148d1 /ui/src/components/password_change.tsx
parent05ee5a8b600fdd7a64ad66bb52978befed3a7614 (diff)
First pass at fixing UI to work with new websocketresponses.
Diffstat (limited to 'ui/src/components/password_change.tsx')
-rw-r--r--ui/src/components/password_change.tsx19
1 files changed, 6 insertions, 13 deletions
diff --git a/ui/src/components/password_change.tsx b/ui/src/components/password_change.tsx
index 3e542f7b..d25c0daf 100644
--- a/ui/src/components/password_change.tsx
+++ b/ui/src/components/password_change.tsx
@@ -7,7 +7,7 @@ import {
PasswordChangeForm,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
-import { msgOp, capitalizeFirstLetter } from '../utils';
+import { wsJsonToRes, capitalizeFirstLetter } from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
@@ -34,14 +34,7 @@ export class PasswordChange extends Component<any, State> {
this.state = this.emptyState;
this.subscription = WebSocketService.Instance.subject
- .pipe(
- retryWhen(errors =>
- errors.pipe(
- delay(3000),
- take(10)
- )
- )
- )
+ .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10))))
.subscribe(
msg => this.parseMessage(msg),
err => console.error(err),
@@ -141,18 +134,18 @@ export class PasswordChange extends Component<any, State> {
}
parseMessage(msg: any) {
- let op: UserOperation = msgOp(msg);
+ let res = wsJsonToRes(msg);
if (msg.error) {
alert(i18n.t(msg.error));
this.state.loading = false;
this.setState(this.state);
return;
} else {
- if (op == UserOperation.PasswordChange) {
+ if (res.op == UserOperation.PasswordChange) {
+ let data = res.data as LoginResponse;
this.state = this.emptyState;
this.setState(this.state);
- let res: LoginResponse = msg;
- UserService.Instance.login(res);
+ UserService.Instance.login(data);
this.props.history.push('/');
}
}