diff options
Diffstat (limited to 'client/src/app/shared/user-subscription/subscribe-button.component.ts')
-rw-r--r-- | client/src/app/shared/user-subscription/subscribe-button.component.ts | 30 |
1 files changed, 14 insertions, 16 deletions
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 315ea5037..8f1754c7f 100644 --- a/client/src/app/shared/user-subscription/subscribe-button.component.ts +++ b/client/src/app/shared/user-subscription/subscribe-button.component.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { Router } from '@angular/router' | 2 | import { Router } from '@angular/router' |
3 | import { AuthService } from '@app/core' | 3 | import { AuthService, Notifier } from '@app/core' |
4 | import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service' | 4 | import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service' |
5 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 5 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
6 | import { NotificationsService } from 'angular2-notifications' | ||
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
8 | import { VideoService } from '@app/shared/video/video.service' | 7 | import { VideoService } from '@app/shared/video/video.service' |
9 | import { FeedFormat } from '../../../../../shared/models/feeds' | 8 | import { FeedFormat } from '../../../../../shared/models/feeds' |
@@ -23,7 +22,7 @@ export class SubscribeButtonComponent implements OnInit { | |||
23 | constructor ( | 22 | constructor ( |
24 | private authService: AuthService, | 23 | private authService: AuthService, |
25 | private router: Router, | 24 | private router: Router, |
26 | private notificationsService: NotificationsService, | 25 | private notifier: Notifier, |
27 | private userSubscriptionService: UserSubscriptionService, | 26 | private userSubscriptionService: UserSubscriptionService, |
28 | private i18n: I18n, | 27 | private i18n: I18n, |
29 | private videoService: VideoService | 28 | private videoService: VideoService |
@@ -43,18 +42,17 @@ export class SubscribeButtonComponent implements OnInit { | |||
43 | .subscribe( | 42 | .subscribe( |
44 | res => this.subscribed = res[this.uri], | 43 | res => this.subscribed = res[this.uri], |
45 | 44 | ||
46 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 45 | err => this.notifier.error(err.message) |
47 | ) | 46 | ) |
48 | } | 47 | } |
49 | } | 48 | } |
50 | 49 | ||
51 | subscribe () { | 50 | subscribe () { |
52 | if (this.isUserLoggedIn()) { | 51 | if (this.isUserLoggedIn()) { |
53 | this.localSubscribe() | 52 | return this.localSubscribe() |
54 | } else { | ||
55 | this.authService.redirectUrl = this.router.url | ||
56 | this.gotoLogin() | ||
57 | } | 53 | } |
54 | |||
55 | return this.gotoLogin() | ||
58 | } | 56 | } |
59 | 57 | ||
60 | localSubscribe () { | 58 | localSubscribe () { |
@@ -63,13 +61,13 @@ export class SubscribeButtonComponent implements OnInit { | |||
63 | () => { | 61 | () => { |
64 | this.subscribed = true | 62 | this.subscribed = true |
65 | 63 | ||
66 | this.notificationsService.success( | 64 | this.notifier.success( |
67 | this.i18n('Subscribed'), | 65 | this.i18n('Subscribed to {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }), |
68 | this.i18n('Subscribed to {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }) | 66 | this.i18n('Subscribed') |
69 | ) | 67 | ) |
70 | }, | 68 | }, |
71 | 69 | ||
72 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 70 | err => this.notifier.error(err.message) |
73 | ) | 71 | ) |
74 | } | 72 | } |
75 | 73 | ||
@@ -85,13 +83,13 @@ export class SubscribeButtonComponent implements OnInit { | |||
85 | () => { | 83 | () => { |
86 | this.subscribed = false | 84 | this.subscribed = false |
87 | 85 | ||
88 | this.notificationsService.success( | 86 | this.notifier.success( |
89 | this.i18n('Unsubscribed'), | 87 | this.i18n('Unsubscribed from {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }), |
90 | this.i18n('Unsubscribed from {{nameWithHost}}', { nameWithHost: this.videoChannel.displayName }) | 88 | this.i18n('Unsubscribed') |
91 | ) | 89 | ) |
92 | }, | 90 | }, |
93 | 91 | ||
94 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 92 | err => this.notifier.error(err.message) |
95 | ) | 93 | ) |
96 | } | 94 | } |
97 | 95 | ||