diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-09-02 20:54:23 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-03 08:49:29 +0200 |
commit | 20d211990425af8d9bb5c8eba204d2b485bcd19a (patch) | |
tree | 020584a5712b153dc1d7e965287c7f384ae722b1 /client/src/app/+video-channels | |
parent | 9a2f7ea799fdd52b24245e94d01f12fabd6efc02 (diff) | |
download | PeerTube-20d211990425af8d9bb5c8eba204d2b485bcd19a.tar.gz PeerTube-20d211990425af8d9bb5c8eba204d2b485bcd19a.tar.zst PeerTube-20d211990425af8d9bb5c8eba204d2b485bcd19a.zip |
add like, dislike and subscribe button hotkeys
Diffstat (limited to 'client/src/app/+video-channels')
-rw-r--r-- | client/src/app/+video-channels/video-channels.component.html | 2 | ||||
-rw-r--r-- | client/src/app/+video-channels/video-channels.component.ts | 22 |
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 @@ | |||
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 () { |