+import { Component, OnInit } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
+import { ChatroomService } from "../chatroom.service";
+import { UserService } from "../user.service";
+import { Chatroom } from "../chatroom";
+
+@Component({
+ selector: 'app-chatroom',
+ templateUrl: './chatroom.component.html',
+ styleUrls: ['./chatroom.component.less']
+})
+export class ChatroomComponent implements OnInit {
+
+ chatroom: Chatroom = { id: 'FOO', name: 'BAR'};
+
+ constructor(
+ private chatroomsService: ChatroomService,
+ private userService: UserService,
+ private route: ActivatedRoute) {}
+
+ ngOnInit(): void
+ {
+ this.userService.assertUserisKnown(() => this.getChatroom());
+ }
+
+ getChatroom(): void {
+ const id: string | null = this.route.snapshot.paramMap.get('id');
+ if (id === null) {
+ console.log("ID for chatroom is missing in URI");
+ }
+ else {
+ this.chatroomsService
+ .getChatroom(id)
+ .subscribe(chatroom => this.chatroom = chatroom);
+ }
+ }
+}