Updated code based on review comments

This commit is contained in:
Wicklow 2023-11-08 09:38:27 +01:00
parent 9c761fb9e0
commit 8cd805fccd
2 changed files with 16 additions and 22 deletions

View File

@ -232,7 +232,7 @@ export class Video implements VideoServerModel {
this.isUpdatableBy(user) this.isUpdatableBy(user)
} }
canSeeStats (user: AuthUser) { isAccessibleBy (user: AuthUser) {
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS)) return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS))
} }
@ -251,14 +251,6 @@ export class Video implements VideoServerModel {
this.hasWebVideos() this.hasWebVideos()
} }
isDownloadableBy (user: AuthUser) {
if (!user || this.isLocal !== true) {
return false
}
return this.account.name === user.username || user.hasRight(UserRight.MANAGE_VIDEO_FILES)
}
canRunTranscoding (user: AuthUser) { canRunTranscoding (user: AuthUser) {
return this.canRunForcedTranscoding(user) && this.state.id !== VideoState.TO_TRANSCODE return this.canRunForcedTranscoding(user) && this.state.id !== VideoState.TO_TRANSCODE
} }

View File

@ -16,6 +16,7 @@ import {
import { LiveStreamInformationComponent } from '../shared-video-live' import { LiveStreamInformationComponent } from '../shared-video-live'
import { VideoAddToPlaylistComponent } from '../shared-video-playlist' import { VideoAddToPlaylistComponent } from '../shared-video-playlist'
import { VideoDownloadComponent } from './video-download.component' import { VideoDownloadComponent } from './video-download.component'
import { of } from 'rxjs'
export type VideoActionsDisplayType = { export type VideoActionsDisplayType = {
playlist?: boolean playlist?: boolean
@ -127,13 +128,14 @@ export class VideoActionsDropdownComponent implements OnChanges {
showDownloadModal () { showDownloadModal () {
this.modalOpened.emit() this.modalOpened.emit()
if (!(this.video instanceof VideoDetails)) {
this.videoService.getVideo({ videoId: this.video.uuid }).subscribe((details: VideoDetails) => { const obs = this.video instanceof VideoDetails
this.videoDownloadModal.show(details, this.videoCaptions) ? of(this.video)
}) : this.videoService.getVideo({ videoId: this.video.uuid })
} else {
this.videoDownloadModal.show(this.video, this.videoCaptions) obs.subscribe((videoDetails: VideoDetails) => {
} this.videoDownloadModal.show(videoDetails, this.videoCaptions)
})
} }
showReportModal () { showReportModal () {
@ -165,7 +167,7 @@ export class VideoActionsDropdownComponent implements OnChanges {
} }
isVideoStatsAvailable () { isVideoStatsAvailable () {
return this.video.canSeeStats(this.user) return this.video.isAccessibleBy(this.user)
} }
isVideoRemovable () { isVideoRemovable () {
@ -185,11 +187,11 @@ export class VideoActionsDropdownComponent implements OnChanges {
} }
isVideoDownloadable () { isVideoDownloadable () {
if (!this.video || this.video.isLive) { return (this.video &&
return false this.video.isLive !== true &&
} this.video instanceof VideoDetails &&
this.video.downloadEnabled) ||
return (this.video instanceof VideoDetails && this.video.downloadEnabled) || this.video.isDownloadableBy(this.user) this.video.isAccessibleBy(this.user)
} }
canVideoBeDuplicated () { canVideoBeDuplicated () {