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 --- client/src/app/+accounts/accounts.component.ts | 64 ++++++++++++++------------ 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'client/src/app/+accounts') diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index b06ecfe0e..ad611f221 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts @@ -35,34 +35,41 @@ export class AccountsComponent implements OnInit, OnDestroy { private redirectService: RedirectService, private authService: AuthService, private i18n: I18n - ) {} + ) { + } ngOnInit () { this.routeSub = this.route.params - .pipe( - map(params => params[ 'accountId' ]), - distinctUntilChanged(), - switchMap(accountId => this.accountService.getAccount(accountId)), - tap(account => { - this.account = account - - this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id - - this.accountFollowerTitle = this.i18n( - '{{followers}} direct account followers', - { followers: this.subscribersDisplayFor(account.followersCount) } - ) - - this.getUserIfNeeded(account) - }), - switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), - catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) - ) - .subscribe( - videoChannels => this.videoChannels = videoChannels.data, - - err => this.notifier.error(err.message) - ) + .pipe( + map(params => params[ 'accountId' ]), + distinctUntilChanged(), + switchMap(accountId => this.accountService.getAccount(accountId)), + tap(account => { + this.account = account + + if (this.authService.isLoggedIn()) { + this.authService.userInformationLoaded.subscribe( + () => { + this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id + + this.accountFollowerTitle = this.i18n( + '{{followers}} direct account followers', + { followers: this.subscribersDisplayFor(account.followersCount) } + ) + } + ) + } + + this.getUserIfNeeded(account) + }), + switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), + catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ])) + ) + .subscribe( + videoChannels => this.videoChannels = videoChannels.data, + + err => this.notifier.error(err.message) + ) } ngOnDestroy () { @@ -97,11 +104,8 @@ export class AccountsComponent implements OnInit, OnDestroy { const user = this.authService.getUser() if (user.hasRight(UserRight.MANAGE_USERS)) { - forkJoin([ - this.userService.getUser(account.userId), - this.authService.userInformationLoaded.pipe(first()) - ]).subscribe( - ([ accountUser ]) => this.accountUser = accountUser, + this.userService.getUser(account.userId).subscribe( + accountUser => this.accountUser = accountUser, err => this.notifier.error(err.message) ) -- cgit v1.2.3