aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-01-10 16:22:55 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-01-10 16:23:55 +0100
commita004ff172638083d69ed1028d18c9b6222d24da6 (patch)
tree6b61eab4035672c4503b84684dc3d470aeb4e20f /client/src
parent333952bc6478358ef6979b35d8dc215283b4717e (diff)
downloadPeerTube-a004ff172638083d69ed1028d18c9b6222d24da6.tar.gz
PeerTube-a004ff172638083d69ed1028d18c9b6222d24da6.tar.zst
PeerTube-a004ff172638083d69ed1028d18c9b6222d24da6.zip
Add naive aggregation from channels to account display of subscribers
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+accounts/accounts.component.html4
-rw-r--r--client/src/app/+accounts/accounts.component.ts13
2 files changed, 15 insertions, 2 deletions
diff --git a/client/src/app/+accounts/accounts.component.html b/client/src/app/+accounts/accounts.component.html
index be40b63ca..57498e98c 100644
--- a/client/src/app/+accounts/accounts.component.html
+++ b/client/src/app/+accounts/accounts.component.html
@@ -28,7 +28,9 @@
28 > 28 >
29 </my-user-moderation-dropdown> 29 </my-user-moderation-dropdown>
30 </div> 30 </div>
31 <div class="actor-followers" i18n>{account.followersCount, plural, =1 {1 subscriber} other {{{ account.followersCount }} subscribers}}</div> 31 <div class="actor-followers" i18n-title [title]="subscribersDisplayFor(account.followersCount) + ' to the account actor'">
32 {{ subscribersDisplayFor(naiveAggregatedSubscribers) }}
33 </div>
32 </div> 34 </div>
33 35
34 <my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button> 36 <my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button>
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts
index 8bde7ad07..da4a0b28e 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'
18export class AccountsComponent implements OnInit, OnDestroy { 18export class AccountsComponent implements OnInit, OnDestroy {
19 account: Account 19 account: Account
20 user: User 20 user: User
21 videoChannels: VideoChannel[] 21 videoChannels: VideoChannel[] = []
22 22
23 private routeSub: Subscription 23 private routeSub: Subscription
24 24
@@ -58,6 +58,13 @@ export class AccountsComponent implements OnInit, OnDestroy {
58 if (this.routeSub) this.routeSub.unsubscribe() 58 if (this.routeSub) this.routeSub.unsubscribe()
59 } 59 }
60 60
61 get naiveAggregatedSubscribers () {
62 return this.videoChannels.reduce(
63 (acc, val) => acc + val.followersCount,
64 this.account.followersCount // accumulator starts with the base number of subscribers the account has
65 )
66 }
67
61 onUserChanged () { 68 onUserChanged () {
62 this.getUserIfNeeded(this.account) 69 this.getUserIfNeeded(this.account)
63 } 70 }
@@ -70,6 +77,10 @@ export class AccountsComponent implements OnInit, OnDestroy {
70 this.notifier.success(this.i18n('Username copied')) 77 this.notifier.success(this.i18n('Username copied'))
71 } 78 }
72 79
80 subscribersDisplayFor (count: number) {
81 return this.i18n(`{count, plural, =1 {1 subscriber} other {${count} subscribers}}`, { count })
82 }
83
73 private getUserIfNeeded (account: Account) { 84 private getUserIfNeeded (account: Account) {
74 if (!account.userId) return 85 if (!account.userId) return
75 if (!this.authService.isLoggedIn()) return 86 if (!this.authService.isLoggedIn()) return