X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Baccounts%2Faccounts.component.ts;h=4fea0e4edc99abdfcdfdf0be2fabf521ca1a47b0;hb=24e7916c6897bbb38e057cdf1a102286006be964;hp=b06ecfe0e49db6fe0c7a03fc28911c0ad4ad6b72;hpb=496b02e38f272622a84ba22db412858d478ae7b0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index b06ecfe0e..4fea0e4ed 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts @@ -10,6 +10,7 @@ import { User, UserRight } from '../../../../shared' import { I18n } from '@ngx-translate/i18n-polyfill' import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' import { VideoChannel } from '@app/shared/video-channel/video-channel.model' +import { ListOverflowItem } from '@app/shared/misc/list-overflow.component' @Component({ templateUrl: './accounts.component.html', @@ -19,6 +20,7 @@ export class AccountsComponent implements OnInit, OnDestroy { account: Account accountUser: User videoChannels: VideoChannel[] = [] + links: ListOverflowItem[] = [] isAccountManageable = false accountFollowerTitle = '' @@ -35,34 +37,47 @@ 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) + ) + + this.links = [ + { label: this.i18n('Video channels'), routerLink: 'video-channels' }, + { label: this.i18n('Videos'), routerLink: 'videos' }, + { label: this.i18n('About'), routerLink: 'about' } + ] } ngOnDestroy () { @@ -89,7 +104,7 @@ export class AccountsComponent implements OnInit, OnDestroy { } subscribersDisplayFor (count: number) { - return this.i18n(`{count, plural, =1 {1 subscriber} other {${count} subscribers}}`, { count }) + return this.i18n('{count, plural, =1 {1 subscriber} other {{{count}} subscribers}}', { count }) } private getUserIfNeeded (account: Account) { @@ -97,11 +112,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) )