From fef213cae10cbbf760b5ec81a1ed154038b59a61 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Jan 2020 15:01:38 +0100 Subject: Fix is managaeble for channels --- .../src/app/+video-channels/video-channels.component.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'client/src/app/+video-channels/video-channels.component.ts') diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts index 493a6d499..7b335b13f 100644 --- a/client/src/app/+video-channels/video-channels.component.ts +++ b/client/src/app/+video-channels/video-channels.component.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { RestExtractor } from '@app/shared' -import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators' +import { catchError, distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators' import { Subscription } from 'rxjs' import { AuthService, Notifier } from '@app/core' import { Hotkey, HotkeysService } from 'angular2-hotkeys' @@ -19,6 +19,7 @@ export class VideoChannelsComponent implements OnInit, OnDestroy { videoChannel: VideoChannel hotkeys: Hotkey[] + isChannelManageable = false private routeSub: Subscription @@ -40,7 +41,17 @@ export class VideoChannelsComponent implements OnInit, OnDestroy { switchMap(videoChannelName => this.videoChannelService.getVideoChannel(videoChannelName)), catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) ) - .subscribe(videoChannel => this.videoChannel = videoChannel) + .subscribe(videoChannel => { + this.videoChannel = videoChannel + + if (this.authService.isLoggedIn()) { + this.authService.userInformationLoaded + .subscribe(() => { + const channelUserId = this.videoChannel.ownerAccount.userId + this.isChannelManageable = channelUserId && channelUserId === this.authService.getUser().id + }) + } + }) this.hotkeys = [ new Hotkey('S', (event: KeyboardEvent): boolean => { -- cgit v1.2.3