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 2d5d534b3e4d806230ec581d7e074a98506f82ea..e78edd031fbff67ced998d4de678bee8882a11ed 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 868f34ada03c2ebc9b30ffb8f581421ae7a34eb5..4566c05902de34f4fc2ef68f1db0f19dcd91516c 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> {