X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Baccounts%2Faccounts.component.ts;h=3d486f084e5ccf02a073d313c7dc98c264a30945;hb=9b82d49da868536701d80ef1071df0e7cd301b7a;hp=8bde7ad070689123a34b1acd9c98b12e1a859918;hpb=9270ccf6dca5b2955ad126947d4296deb385fdcb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index 8bde7ad07..3d486f084 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts @@ -18,7 +18,7 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model' export class AccountsComponent implements OnInit, OnDestroy { account: Account user: User - videoChannels: VideoChannel[] + videoChannels: VideoChannel[] = [] private routeSub: Subscription @@ -58,6 +58,18 @@ export class AccountsComponent implements OnInit, OnDestroy { if (this.routeSub) this.routeSub.unsubscribe() } + get naiveAggregatedSubscribers () { + return this.videoChannels.reduce( + (acc, val) => acc + val.followersCount, + this.account.followersCount // accumulator starts with the base number of subscribers the account has + ) + } + + get isManageable () { + if (!this.authService.isLoggedIn()) return false + return this.user.id === this.authService.getUser().id + } + onUserChanged () { this.getUserIfNeeded(this.account) } @@ -70,6 +82,10 @@ export class AccountsComponent implements OnInit, OnDestroy { this.notifier.success(this.i18n('Username copied')) } + subscribersDisplayFor (count: number) { + return this.i18n(`{count, plural, =1 {1 subscriber} other {${count} subscribers}}`, { count }) + } + private getUserIfNeeded (account: Account) { if (!account.userId) return if (!this.authService.isLoggedIn()) return