mirror of https://github.com/Chocobozzz/PeerTube
Add naive aggregation from channels to account display of subscribers
This commit is contained in:
parent
333952bc64
commit
a004ff1726
|
@ -28,7 +28,9 @@
|
||||||
>
|
>
|
||||||
</my-user-moderation-dropdown>
|
</my-user-moderation-dropdown>
|
||||||
</div>
|
</div>
|
||||||
<div class="actor-followers" i18n>{account.followersCount, plural, =1 {1 subscriber} other {{{ account.followersCount }} subscribers}}</div>
|
<div class="actor-followers" i18n-title [title]="subscribersDisplayFor(account.followersCount) + ' to the account actor'">
|
||||||
|
{{ subscribersDisplayFor(naiveAggregatedSubscribers) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button>
|
<my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button>
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
||||||
export class AccountsComponent implements OnInit, OnDestroy {
|
export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
account: Account
|
account: Account
|
||||||
user: User
|
user: User
|
||||||
videoChannels: VideoChannel[]
|
videoChannels: VideoChannel[] = []
|
||||||
|
|
||||||
private routeSub: Subscription
|
private routeSub: Subscription
|
||||||
|
|
||||||
|
@ -58,6 +58,13 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
if (this.routeSub) this.routeSub.unsubscribe()
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
onUserChanged () {
|
onUserChanged () {
|
||||||
this.getUserIfNeeded(this.account)
|
this.getUserIfNeeded(this.account)
|
||||||
}
|
}
|
||||||
|
@ -70,6 +77,10 @@ export class AccountsComponent implements OnInit, OnDestroy {
|
||||||
this.notifier.success(this.i18n('Username copied'))
|
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) {
|
private getUserIfNeeded (account: Account) {
|
||||||
if (!account.userId) return
|
if (!account.userId) return
|
||||||
if (!this.authService.isLoggedIn()) return
|
if (!this.authService.isLoggedIn()) return
|
||||||
|
|
Loading…
Reference in New Issue