Fix dropdown on video miniature for unlogged users
authorChocobozzz <me@florianbigard.com>
Fri, 6 Dec 2019 10:07:30 +0000 (11:07 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 6 Dec 2019 10:07:30 +0000 (11:07 +0100)
client/src/app/+about/about-peertube/about-peertube.component.html
client/src/app/shared/buttons/action-dropdown.component.html
client/src/app/shared/buttons/action-dropdown.component.ts
client/src/app/videos/+video-watch/video-watch.component.ts

index 5c63052d8fe32fe0a4354a2af15e00089c01076b..c6f21d35abd6fb26442f7f4923811444589c8ddc 100644 (file)
   </p>
 </div>
 
+<div class="documentation">
+
+
+</div>
+
 <div class="privacy-contributors">
   <my-about-peertube-contributors></my-about-peertube-contributors>
 
index cc244dc760ad5f710b6ddf7ec9b25cb5170c54df..99e8b7ec1651482c39dc0c1285777cb83e3f15dc 100644 (file)
@@ -1,4 +1,4 @@
-<div class="dropdown-root" ngbDropdown [placement]="placement">
+<div class="dropdown-root" ngbDropdown [placement]="placement" *ngIf="areActionsDisplayed(actions, entry)">
   <div
     class="action-button" [ngClass]="{ small: buttonSize === 'small', grey: theme === 'grey', orange: theme === 'orange', 'button-styled': buttonStyled }"
     ngbDropdownToggle role="button"
index c9dbbfda243035c10b905903ae5ba594e6f0de9e..a4200f70f7ad97417fa98967a0f8872178b96e4a 100644 (file)
@@ -38,7 +38,11 @@ export class ActionDropdownComponent<T> {
     return [ this.actions ]
   }
 
-  areActionsDisplayed (actions: DropdownAction<T>[], entry: T) {
-    return actions.some(a => a.isDisplayed === undefined || a.isDisplayed(entry))
+  areActionsDisplayed (actions: Array<DropdownAction<T> | DropdownAction<T>[]>, entry: T): boolean {
+    return actions.some(a => {
+      if (Array.isArray(a)) return this.areActionsDisplayed(a, entry)
+
+      return a.isDisplayed === undefined || a.isDisplayed(entry)
+    })
   }
 }
index eee7adfd883484dfdcfde4cdef23847bfa6416a3..0de621acabed48b90195b8c21dd8fe00e9162d6d 100644 (file)
@@ -69,7 +69,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   likesBarTooltipText = ''
   hasAlreadyAcceptedPrivacyConcern = false
   remoteServerDown = false
-  hotkeys: Hotkey[]
+  hotkeys: Hotkey[] = []
 
   private nextVideoUuid = ''
   private currentTime: number
@@ -147,7 +147,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     if (this.queryParamsSub) this.queryParamsSub.unsubscribe()
 
     // Unbind hotkeys
-    if (this.isUserLoggedIn()) this.hotkeysService.remove(this.hotkeys)
+    this.hotkeysService.remove(this.hotkeys)
   }
 
   setLike () {
@@ -650,21 +650,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
   private initHotkeys () {
     this.hotkeys = [
-      new Hotkey('shift+l', () => {
-        this.setLike()
-        return false
-      }, undefined, this.i18n('Like the video')),
-
-      new Hotkey('shift+d', () => {
-        this.setDislike()
-        return false
-      }, undefined, this.i18n('Dislike the video')),
-
-      new Hotkey('shift+s', () => {
-        this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
-        return false
-      }, undefined, this.i18n('Subscribe to the account')),
-
       // These hotkeys are managed by the player
       new Hotkey('f', e => e, undefined, this.i18n('Enter/exit fullscreen (requires player focus)')),
       new Hotkey('space', e => e, undefined, this.i18n('Play/Pause the video (requires player focus)')),
@@ -683,6 +668,26 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
       new Hotkey('.', e => e, undefined, this.i18n('Navigate in the video frame by frame (requires player focus)'))
     ]
-    if (this.isUserLoggedIn()) this.hotkeysService.add(this.hotkeys)
+
+    if (this.isUserLoggedIn()) {
+      this.hotkeys = this.hotkeys.concat([
+        new Hotkey('shift+l', () => {
+          this.setLike()
+          return false
+        }, undefined, this.i18n('Like the video')),
+
+        new Hotkey('shift+d', () => {
+          this.setDislike()
+          return false
+        }, undefined, this.i18n('Dislike the video')),
+
+        new Hotkey('shift+s', () => {
+          this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
+          return false
+        }, undefined, this.i18n('Subscribe to the account'))
+      ])
+    }
+
+    this.hotkeysService.add(this.hotkeys)
   }
 }