diff options
Diffstat (limited to 'client/src/app/+video-channels/video-channels.component.ts')
-rw-r--r-- | client/src/app/+video-channels/video-channels.component.ts | 22 |
1 files changed, 20 insertions, 2 deletions
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 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute } from '@angular/router' | 2 | import { ActivatedRoute } from '@angular/router' |
3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 3 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
4 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 4 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
@@ -6,13 +6,18 @@ import { RestExtractor } from '@app/shared' | |||
6 | import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators' | 6 | import { catchError, distinctUntilChanged, map, switchMap } from 'rxjs/operators' |
7 | import { Subscription } from 'rxjs' | 7 | import { Subscription } from 'rxjs' |
8 | import { AuthService } from '@app/core' | 8 | import { AuthService } from '@app/core' |
9 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' | ||
10 | import { 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 | }) |
14 | export class VideoChannelsComponent implements OnInit, OnDestroy { | 16 | export 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 () { |