Commit df599dd7 authored by Lukas Burgey's avatar Lukas Burgey

Add some types

parent ed1d192a
...@@ -96,7 +96,7 @@ export interface StateAPIResult { ...@@ -96,7 +96,7 @@ export interface StateAPIResult {
user: User; user: User;
user_state: UserState; user_state: UserState;
services: Service[]; services: Service[];
error: string; error?: string;
} }
......
...@@ -78,16 +78,18 @@ export class UserService { ...@@ -78,16 +78,18 @@ export class UserService {
subscription.map((message: Message) => { subscription.map((message: Message) => {
return message.body; return message.body;
}).subscribe((body: any) => { }).subscribe(
let json = JSON.parse(body); (body: any) => {
if (json.message && json.message != '') { let json : t.StateAPIResult = JSON.parse(body);
this.snackBar.open(json.message); if (json.error && json.error != '') {
this.messages.push(json.message); this.snackBar.open(json.error);
} this.messages.push(json.error);
if (json.user_state) { }
this.updateUserState(json.user_state); if (json.user_state) {
this.updateUserState(json.user_state);
}
} }
}); );
} }
private updateUser(newUser: t.User) { private updateUser(newUser: t.User) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment