]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/hotkeys/hotkeys.component.ts
Fix video files duplicated when fps is null
[github/Chocobozzz/PeerTube.git] / client / src / app / core / hotkeys / hotkeys.component.ts
CommitLineData
7aba23d1
RK
1import { Component, OnInit, OnDestroy, Input } from '@angular/core'
2import { Subscription } from 'rxjs'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { HotkeysService, Hotkey } from 'angular2-hotkeys'
5
6@Component({
7 selector : 'my-hotkeys-cheatsheet',
8 templateUrl : './hotkeys.component.html',
9 styleUrls: [ './hotkeys.component.scss' ]
10})
11export class CheatSheetComponent implements OnInit, OnDestroy {
7aba23d1 12 @Input() title = this.i18n('Keyboard Shortcuts:')
bcb0c895 13 helpVisible = false
7aba23d1
RK
14 subscription: Subscription
15
16 hotkeys: Hotkey[]
17
18 constructor (
19 private hotkeysService: HotkeysService,
20 private i18n: I18n
21 ) {}
22
23 public ngOnInit (): void {
24 this.subscription = this.hotkeysService.cheatSheetToggle.subscribe((isOpen) => {
25 if (isOpen !== false) {
26 this.hotkeys = this.hotkeysService.hotkeys.filter(hotkey => hotkey.description)
27 }
28
29 if (isOpen === false) {
30 this.helpVisible = false
31 } else {
32 this.toggleCheatSheet()
33 }
34 })
35 }
36
37 public ngOnDestroy (): void {
38 if (this.subscription) {
39 this.subscription.unsubscribe()
40 }
41 }
42
43 public toggleCheatSheet (): void {
44 this.helpVisible = !this.helpVisible
45 }
46}