X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fvideo-actions-dropdown.component.ts;h=7f3e25d0aace4eb58f035545e6d585ea0ea5cfd5;hb=dd570a34ff731a6cd98ef8f8bf83f234e804f6c1;hp=b2d77a9e675fab722c507ef7c4b455c8b85465e0;hpb=743f023c5361af1428e927171effb2616d4e0245;p=oweals%2Fpeertube.git diff --git a/client/src/app/shared/video/video-actions-dropdown.component.ts b/client/src/app/shared/video/video-actions-dropdown.component.ts index b2d77a9e6..7f3e25d0a 100644 --- a/client/src/app/shared/video/video-actions-dropdown.component.ts +++ b/client/src/app/shared/video/video-actions-dropdown.component.ts @@ -1,4 +1,4 @@ -import { AfterContentInit, AfterViewInit, Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core' +import { AfterViewInit, Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core' import { I18n } from '@ngx-translate/i18n-polyfill' import { DropdownAction, DropdownButtonSize, DropdownDirection } from '@app/shared/buttons/action-dropdown.component' import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' @@ -28,13 +28,13 @@ export type VideoActionsDisplayType = { templateUrl: './video-actions-dropdown.component.html', styleUrls: [ './video-actions-dropdown.component.scss' ] }) -export class VideoActionsDropdownComponent implements AfterViewInit, OnChanges { - @ViewChild('playlistDropdown') playlistDropdown: NgbDropdown - @ViewChild('playlistAdd') playlistAdd: VideoAddToPlaylistComponent +export class VideoActionsDropdownComponent implements OnChanges { + @ViewChild('playlistDropdown', { static: false }) playlistDropdown: NgbDropdown + @ViewChild('playlistAdd', { static: false }) playlistAdd: VideoAddToPlaylistComponent - @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent - @ViewChild('videoReportModal') videoReportModal: VideoReportComponent - @ViewChild('videoBlacklistModal') videoBlacklistModal: VideoBlacklistComponent + @ViewChild('videoDownloadModal', { static: false }) videoDownloadModal: VideoDownloadComponent + @ViewChild('videoReportModal', { static: false }) videoReportModal: VideoReportComponent + @ViewChild('videoBlacklistModal', { static: false }) videoBlacklistModal: VideoBlacklistComponent @Input() video: Video | VideoDetails @@ -78,14 +78,12 @@ export class VideoActionsDropdownComponent implements AfterViewInit, OnChanges { return this.authService.getUser() } - ngAfterViewInit () { - // We rely on mouseenter to lazy load actions - if (this.screenService.isInTouchScreen()) { - this.loadDropdownInformation() + ngOnChanges () { + if (this.loaded) { + this.loaded = false + this.playlistAdd.reload() } - } - ngOnChanges () { this.buildActions() } @@ -133,6 +131,10 @@ export class VideoActionsDropdownComponent implements AfterViewInit, OnChanges { return this.video.isUnblacklistableBy(this.user) } + isVideoDownloadable () { + return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled + } + /* Action handlers */ async unblacklistVideo () { @@ -186,59 +188,55 @@ export class VideoActionsDropdownComponent implements AfterViewInit, OnChanges { } private buildActions () { - this.videoActions = [] - - if (this.authService.isLoggedIn()) { - this.videoActions.push([ + this.videoActions = [ + [ { label: this.i18n('Save to playlist'), handler: () => this.playlistDropdown.toggle(), - isDisplayed: () => this.displayOptions.playlist, + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.playlist, iconName: 'playlist-add' } - ]) - - this.videoActions.push([ + ], + [ { label: this.i18n('Download'), handler: () => this.showDownloadModal(), - isDisplayed: () => this.displayOptions.download, + isDisplayed: () => this.displayOptions.download && this.isVideoDownloadable(), iconName: 'download' }, { label: this.i18n('Update'), linkBuilder: ({ video }) => [ '/videos/update', video.uuid ], iconName: 'edit', - isDisplayed: () => this.displayOptions.update && this.isVideoUpdatable() + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.update && this.isVideoUpdatable() }, { label: this.i18n('Blacklist'), handler: () => this.showBlacklistModal(), iconName: 'no', - isDisplayed: () => this.displayOptions.blacklist && this.isVideoBlacklistable() + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.blacklist && this.isVideoBlacklistable() }, { label: this.i18n('Unblacklist'), handler: () => this.unblacklistVideo(), iconName: 'undo', - isDisplayed: () => this.displayOptions.blacklist && this.isVideoUnblacklistable() + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.blacklist && this.isVideoUnblacklistable() }, { label: this.i18n('Delete'), handler: () => this.removeVideo(), - isDisplayed: () => this.displayOptions.delete && this.isVideoRemovable(), + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.delete && this.isVideoRemovable(), iconName: 'delete' } - ]) - - this.videoActions.push([ + ], + [ { label: this.i18n('Report'), handler: () => this.showReportModal(), - isDisplayed: () => this.displayOptions.report, + isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.report, iconName: 'alert' } - ]) - } + ] + ] } }