X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fuser-subscription%2Fsubscribe-button.component.ts;h=947f34c852236e215304c68c089ab35315a0a536;hb=f8b65c22a9cbf60a1d359c6aa2744baede1ee05f;hp=81a0df512313909b663f13f9813027169448b2a6;hpb=ab4d4db44a4f943056b856cbdc7b8d157cabf9af;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/user-subscription/subscribe-button.component.ts b/client/src/app/shared/user-subscription/subscribe-button.component.ts index 81a0df512..947f34c85 100644 --- a/client/src/app/shared/user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/user-subscription/subscribe-button.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core' +import { Component, Input, OnInit, OnChanges } from '@angular/core' import { Router } from '@angular/router' import { AuthService, Notifier } from '@app/core' import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service' @@ -8,14 +8,13 @@ import { VideoService } from '@app/shared/video/video.service' import { FeedFormat } from '../../../../../shared/models/feeds' import { Account } from '@app/shared/account/account.model' import { concat, forkJoin, merge } from 'rxjs' -import { toArray } from 'rxjs/operators' @Component({ selector: 'my-subscribe-button', templateUrl: './subscribe-button.component.html', styleUrls: [ './subscribe-button.component.scss' ] }) -export class SubscribeButtonComponent implements OnInit { +export class SubscribeButtonComponent implements OnInit, OnChanges { /** * SubscribeButtonComponent can be used with a single VideoChannel passed as [VideoChannel], * or with an account and a full list of that account's videoChannels. The latter is intended @@ -70,10 +69,26 @@ export class SubscribeButtonComponent implements OnInit { return this.videoChannels[0] } + get isAllChannelsSubscribed () { + return this.subscribeStatus(true).length === this.videoChannels.length + } + + get isAtLeastOneChannelSubscribed () { + return this.subscribeStatus(true).length > 0 + } + + get isBigButton () { + return this.isUserLoggedIn() && this.videoChannels.length > 1 && this.isAtLeastOneChannelSubscribed + } + ngOnInit () { this.loadSubscribedStatus() } + ngOnChanges () { + this.ngOnInit() + } + subscribe () { if (this.isUserLoggedIn()) { return this.localSubscribe() @@ -146,18 +161,6 @@ export class SubscribeButtonComponent implements OnInit { return this.authService.isLoggedIn() } - isAllChannelsSubscribed () { - return !Array.from(this.subscribed.values()).includes(false) - } - - isAtLeastOneChannelSubscribed () { - return this.subscribeStatus(true).length > 0 - } - - isBigButton () { - return this.isUserLoggedIn() && this.videoChannels.length > 1 && this.isAtLeastOneChannelSubscribed() - } - gotoLogin () { this.router.navigate([ '/login' ]) }