X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-user-subscription%2Fsubscribe-button.component.ts;h=a002bf4e7d749919297e20df7e1c02f1ab6b365c;hb=HEAD;hp=2261e07dd5f47cda9458c35620ba5726eea074c6;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts index 2261e07dd..a002bf4e7 100644 --- a/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/shared-user-subscription/subscribe-button.component.ts @@ -1,7 +1,6 @@ import { concat, forkJoin, merge } from 'rxjs' import { Component, Input, OnChanges, OnInit } from '@angular/core' -import { Router } from '@angular/router' -import { AuthService, Notifier } from '@app/core' +import { AuthService, Notifier, RedirectService } from '@app/core' import { Account, VideoChannel, VideoService } from '@app/shared/shared-main' import { FeedFormat } from '@shared/models' import { UserSubscriptionService } from './user-subscription.service' @@ -27,7 +26,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { constructor ( private authService: AuthService, - private router: Router, + private redirectService: RedirectService, private notifier: Notifier, private userSubscriptionService: UserSubscriptionService, private videoService: VideoService @@ -102,8 +101,8 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { .map(handle => this.userSubscriptionService.addSubscription(handle)) forkJoin(observableBatch) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success( this.account ? $localize`Subscribed to all current channels of ${this.account.displayName}. You will be notified of all their new videos.` @@ -113,8 +112,8 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { ) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } unsubscribe () { @@ -137,7 +136,7 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { this.notifier.success( this.account ? $localize`Unsubscribed from all channels of ${this.account.nameWithHost}` - : $localize`Unsubscribed from ${this.videoChannels[ 0 ].nameWithHost}`, + : $localize`Unsubscribed from ${this.videoChannels[0].nameWithHost}`, $localize`Unsubscribed` ) @@ -152,12 +151,12 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { } gotoLogin () { - this.router.navigate([ '/login' ]) + this.redirectService.redirectToLogin() } subscribeStatus (subscribed: boolean) { const accumulator: string[] = [] - for (const [key, value] of this.subscribed.entries()) { + for (const [ key, value ] of this.subscribed.entries()) { if (value === subscribed) accumulator.push(key) } @@ -168,6 +167,10 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { return Array.from(this.subscribed.values()).every(v => v === true) } + isRemoteSubscribeAvailable () { + return !this.isUserLoggedIn() + } + private getChannelHandler (videoChannel: VideoChannel) { return videoChannel.name + '@' + videoChannel.host } @@ -182,11 +185,11 @@ export class SubscribeButtonComponent implements OnInit, OnChanges { merge( this.userSubscriptionService.listenToSubscriptionCacheChange(handle), this.userSubscriptionService.doesSubscriptionExist(handle) - ).subscribe( - res => this.subscribed.set(handle, res), + ).subscribe({ + next: res => this.subscribed.set(handle, res), - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } } }