From 757f3434d942312b927279e530325eb03cca5eac Mon Sep 17 00:00:00 2001
From: Lukas Kimpel <lukas.kimpel@mni.thm.de>
Date: Tue, 20 Mar 2018 11:41:49 +0100
Subject: [PATCH] Add submit type to button Remove empty line Revert unneeded
 changes Remove leading space Reduce double code

---
 src/app/join-room/join-room.component.html     |  2 +-
 src/app/join-room/join-room.component.ts       |  1 -
 .../room-creation/room-creation.component.ts   |  2 +-
 src/app/room-list/room-list.component.ts       | 18 ++++++++----------
 src/app/room/room.component.ts                 |  4 +++-
 5 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/app/join-room/join-room.component.html b/src/app/join-room/join-room.component.html
index 8a9c3d75a..a90377652 100644
--- a/src/app/join-room/join-room.component.html
+++ b/src/app/join-room/join-room.component.html
@@ -7,7 +7,7 @@
         <mat-error *ngIf="roomFormControl.hasError('required')">Please enter a room-id.</mat-error>
         <mat-error *ngIf="roomFormControl.hasError('minlength')">A room-id has exactly 8 digits.</mat-error>
       </mat-form-field>
-      <button mat-fab color="primary">
+      <button mat-fab color="primary" type="submit">
         <mat-icon>send</mat-icon>
       </button>
     </div>
diff --git a/src/app/join-room/join-room.component.ts b/src/app/join-room/join-room.component.ts
index a8f169f0d..113255d63 100644
--- a/src/app/join-room/join-room.component.ts
+++ b/src/app/join-room/join-room.component.ts
@@ -59,5 +59,4 @@ export class JoinRoomComponent implements OnInit {
   joinDemo(): void {
     this.getRoom(this.demoId);
   }
-
 }
diff --git a/src/app/room-creation/room-creation.component.ts b/src/app/room-creation/room-creation.component.ts
index 836132721..308a0341c 100644
--- a/src/app/room-creation/room-creation.component.ts
+++ b/src/app/room-creation/room-creation.component.ts
@@ -46,7 +46,7 @@ export class RoomCreationComponent implements OnInit {
       name: longRoomName,
       abbreviation: shortRoomName,
       description: description
-    } as Room).subscribe( room => this.room = room);
+    } as Room).subscribe(room => this.room = room);
     this.roomService.getRoomById(this.roomId)
       .subscribe(room => {
         this.room = room;
diff --git a/src/app/room-list/room-list.component.ts b/src/app/room-list/room-list.component.ts
index 0181fad40..cf5720a1b 100644
--- a/src/app/room-list/room-list.component.ts
+++ b/src/app/room-list/room-list.component.ts
@@ -35,17 +35,15 @@ export class RoomListComponent implements OnInit {
 
   getRooms(): void {
     if (this.authenticationService.getRole() === UserRole.CREATOR) {
-      this.roomService.getCreatorRooms().subscribe(rooms => {
-        this.rooms = rooms;
-        this.closedRooms = this.rooms.filter(room => room.closed);
-        this.isLoading = false;
-      });
+      this.roomService.getCreatorRooms().subscribe(rooms => this.updateRoomList(rooms));
     } else if (this.authenticationService.getRole() === UserRole.PARTICIPANT) {
-      this.roomService.getParticipantRooms().subscribe(rooms => {
-        this.rooms = rooms;
-        this.closedRooms = this.rooms.filter(room => room.closed);
-        this.isLoading = false;
-      });
+      this.roomService.getParticipantRooms().subscribe(rooms => this.updateRoomList(rooms));
     }
   }
+
+  updateRoomList(rooms: Room[]) {
+    this.rooms = rooms;
+    this.closedRooms = this.rooms.filter(room => room.closed);
+    this.isLoading = false;
+  }
 }
diff --git a/src/app/room/room.component.ts b/src/app/room/room.component.ts
index 4c25a1704..1d4c01da8 100644
--- a/src/app/room/room.component.ts
+++ b/src/app/room/room.component.ts
@@ -19,7 +19,9 @@ export class RoomComponent implements OnInit {
   }
 
   ngOnInit() {
-
+    this.route.params.subscribe(params => {
+      this.getRoom(params['roomId']);
+    });
   }
 
   getRoom(id: string): void {
-- 
GitLab