Skip to content
Snippets Groups Projects
Verified Commit 94bc92cb authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Refactor AppRoutingeModule

Remove unnecassary api call for room to get room id (?!)
parent d2c925ae
1 merge request!86Resolve "content types (classes)"
Pipeline #13450 passed with stage
in 33 seconds
......@@ -58,7 +58,7 @@ const routes: Routes = [
data: { roles: [UserRole.CREATOR] }
},
{
path: 'creator/room/:roomId/:id',
path: 'creator/room/:roomId/:contentId',
component: ContentDetailComponent,
canActivate: [AuthenticationGuard],
data: { roles: [UserRole.CREATOR] }
......
......@@ -18,12 +18,12 @@ export class ContentDetailComponent implements OnInit {
ngOnInit() {
this.route.params.subscribe(params => {
this.getContent(params['id']);
this.getContent(params['contentId']);
});
}
getContent(id: string): void {
this.contentService.getContent(id)
getContent(contentId: string): void {
this.contentService.getContent(contentId)
.subscribe(content => this.content = content);
}
}
......@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core';
import { ContentService } from '../content.service';
import { Content } from '../content';
import { ActivatedRoute } from '@angular/router';
import { RoomService } from '../room.service';
@Component({
selector: 'app-content-list',
......@@ -12,29 +11,20 @@ import { RoomService } from '../room.service';
export class ContentListComponent implements OnInit {
contents: Content[];
constructor(
private contentService: ContentService,
private route: ActivatedRoute,
private roomService: RoomService,
) { }
constructor(private contentService: ContentService,
private route: ActivatedRoute) {
}
ngOnInit() {
this.route.params.subscribe(params => {
this.getRoom(params['roomId']);
this.getContents(params['roomId']);
});
}
getRoom(id: string): void {
this.roomService.getRoom(id).subscribe(
params => {
this.getContents(params['id']);
});
}
getContents(roomId: string): void {
this.contentService.getContents(roomId)
.subscribe(contents => {
this.contents = contents;
});
.subscribe(contents => {
this.contents = contents;
});
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment