aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+video-channels
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+video-channels')
-rw-r--r--client/src/app/+video-channels/video-channels.component.html2
-rw-r--r--client/src/app/+video-channels/video-channels.component.ts22
2 files changed, 21 insertions, 3 deletions
diff --git a/client/src/app/+video-channels/video-channels.component.html b/client/src/app/+video-channels/video-channels.component.html
index e5a32dc92..8d6f81e1b 100644
--- a/client/src/app/+video-channels/video-channels.component.html
+++ b/client/src/app/+video-channels/video-channels.component.html
@@ -9,7 +9,7 @@
9 <div class="actor-display-name">{{ videoChannel.displayName }}</div> 9 <div class="actor-display-name">{{ videoChannel.displayName }}</div>
10 <div class="actor-name">{{ videoChannel.nameWithHost }}</div> 10 <div class="actor-name">{{ videoChannel.nameWithHost }}</div>
11 11
12 <my-subscribe-button *ngIf="isUserLoggedIn()" [videoChannel]="videoChannel"></my-subscribe-button> 12 <my-subscribe-button #subscribeButton *ngIf="isUserLoggedIn()" [videoChannel]="videoChannel"></my-subscribe-button>
13 </div> 13 </div>
14 <div i18n class="actor-followers">{{ videoChannel.followersCount }} subscribers</div> 14 <div i18n class="actor-followers">{{ videoChannel.followersCount }} subscribers</div>
15 15
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts
index ee2c86915..82b4a345e 100644
--- a/client/src/app/+video-channels/video-channels.component.ts
+++ b/client/src/app/+video-channels/video-channels.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 3import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 4import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
@@ -6,13 +6,18 @@ import { RestExtractor } from '@app/shared'
6import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators' 6import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators'
7import { Subscription } from 'rxjs' 7import { Subscription } from 'rxjs'
8import { AuthService } from '@app/core' 8import { AuthService } from '@app/core'
9import { Hotkey, HotkeysService } from 'angular2-hotkeys'
10import { SubscribeButtonComponent } from '@app/shared/user-subscription/subscribe-button.component'
9 11
10@Component({ 12@Component({
11 templateUrl: './video-channels.component.html', 13 templateUrl: './video-channels.component.html',
12 styleUrls: [ './video-channels.component.scss' ] 14 styleUrls: [ './video-channels.component.scss' ]
13}) 15})
14export class VideoChannelsComponent implements OnInit, OnDestroy { 16export class VideoChannelsComponent implements OnInit, OnDestroy {
17 @ViewChild('subscribeButton') subscribeButton: SubscribeButtonComponent
18
15 videoChannel: VideoChannel 19 videoChannel: VideoChannel
20 hotkeys: Hotkey[]
16 21
17 private routeSub: Subscription 22 private routeSub: Subscription
18 23
@@ -20,7 +25,8 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
20 private route: ActivatedRoute, 25 private route: ActivatedRoute,
21 private authService: AuthService, 26 private authService: AuthService,
22 private videoChannelService: VideoChannelService, 27 private videoChannelService: VideoChannelService,
23 private restExtractor: RestExtractor 28 private restExtractor: RestExtractor,
29 private hotkeysService: HotkeysService
24 ) { } 30 ) { }
25 31
26 ngOnInit () { 32 ngOnInit () {
@@ -33,10 +39,22 @@ export class VideoChannelsComponent implements OnInit, OnDestroy {
33 ) 39 )
34 .subscribe(videoChannel => this.videoChannel = videoChannel) 40 .subscribe(videoChannel => this.videoChannel = videoChannel)
35 41
42 this.hotkeys = [
43 new Hotkey('S', (event: KeyboardEvent): boolean => {
44 this.subscribeButton.subscribed ?
45 this.subscribeButton.unsubscribe() :
46 this.subscribeButton.subscribe()
47 return false
48 }, undefined, 'Subscribe to the account')
49 ]
50 if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
36 } 51 }
37 52
38 ngOnDestroy () { 53 ngOnDestroy () {
39 if (this.routeSub) this.routeSub.unsubscribe() 54 if (this.routeSub) this.routeSub.unsubscribe()
55
56 // Unbind hotkeys
57 if (this.isUserLoggedIn()) this.hotkeysService.remove(this.hotkeys)
40 } 58 }
41 59
42 isUserLoggedIn () { 60 isUserLoggedIn () {