From 4179fa177e75db5282f89c4b8ad211b388e21b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de> Date: Tue, 19 Feb 2019 12:31:06 +0100 Subject: [PATCH] Fix login and navigation --- .../shared/room-join/room-join.component.ts | 17 +++++++++++------ src/app/services/http/room.service.ts | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/components/shared/room-join/room-join.component.ts b/src/app/components/shared/room-join/room-join.component.ts index 2d5d534b3..e78edd031 100644 --- a/src/app/components/shared/room-join/room-join.component.ts +++ b/src/app/components/shared/room-join/room-join.component.ts @@ -29,7 +29,6 @@ export class RoomJoinComponent implements OnInit { room: Room; demoId = '95680586'; user: User; - loggedIn: string; roomFormControl = new FormControl('', [Validators.required, Validators.minLength(8)]); @@ -43,6 +42,7 @@ export class RoomJoinComponent implements OnInit { } ngOnInit() { + this.authenticationService.watchUser.subscribe(newUser => this.user = newUser); } getRoom(id: string): void { @@ -56,12 +56,12 @@ export class RoomJoinComponent implements OnInit { } else { if (!this.user) { this.authenticationService.guestLogin(UserRole.PARTICIPANT).subscribe(loggedIn => { - this.loggedIn = loggedIn; + if (loggedIn === 'true') { + this.addAndNavigate(); + } }); - } - if (this.loggedIn = 'true') { - this.roomService.addToHistory(this.room.id); - this.router.navigate([`/participant/room/${id}`]); + } else { + this.addAndNavigate(); } } }); @@ -73,6 +73,11 @@ export class RoomJoinComponent implements OnInit { } } + addAndNavigate() { + this.roomService.addToHistory(this.room.id); + this.router.navigate([`/participant/room/${this.room.shortId}`]); + } + joinDemo(): void { this.getRoom(this.demoId); } diff --git a/src/app/services/http/room.service.ts b/src/app/services/http/room.service.ts index 868f34ada..4566c0590 100644 --- a/src/app/services/http/room.service.ts +++ b/src/app/services/http/room.service.ts @@ -75,7 +75,7 @@ export class RoomService extends BaseHttpService { addToHistory(roomId: string): void { const connectionUrl = `${ this.apiUrl.base + this.apiUrl.user }/${ this.authService.getUser().id }/roomHistory`; - this.http.post(connectionUrl, { roomId: roomId, lastVisit: this.joinDate.getTime() }, httpOptions).subscribe(r => console.log(r)); + this.http.post(connectionUrl, { roomId: roomId, lastVisit: this.joinDate.getTime() }, httpOptions).subscribe(); } updateRoom(updatedRoom: Room): Observable<Room> { -- GitLab