From 16757be5a8c3501ff0b0f4f87bb4068a4363cabf Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 7 Jan 2023 19:44:03 +0100 Subject: [PATCH] fix: chatroom redirects to chatrooms, if the chatroom-id is missing --- src/app/chatroom/chatroom.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/chatroom/chatroom.component.ts b/src/app/chatroom/chatroom.component.ts index a25b09c0..7178a5a8 100644 --- a/src/app/chatroom/chatroom.component.ts +++ b/src/app/chatroom/chatroom.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, NgZone } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { ChatroomService } from "../chatroom.service"; import { UserService } from "../user.service"; import { Chatroom } from "../chatroom"; @@ -16,6 +16,7 @@ export class ChatroomComponent implements OnInit { messages: Message[] = []; constructor( + private router: Router, private chatroomsService: ChatroomService, private userService: UserService, private route: ActivatedRoute, @@ -30,6 +31,7 @@ export class ChatroomComponent implements OnInit { const id: string | null = this.route.snapshot.paramMap.get('id'); if (id === null) { console.log("ID for chatroom is missing in URI"); + this.router.navigate(['chatrooms']); } else { this.chatroomsService -- 2.20.1