From 15e9d5ca39e0b792f61453fbf3885a0fc446afa7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Mar 2019 11:40:42 +0100 Subject: Playlist reorder support --- server/controllers/api/video-playlist.ts | 8 +++++--- server/models/video/video.ts | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index 49432d3aa..0a7ff92df 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -41,6 +41,7 @@ import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playli import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' import { copy, pathExists } from 'fs-extra' import { AccountModel } from '../../models/account/account' +import { VideoPlaylistReorder } from '../../../shared/models/videos/playlist/video-playlist-reorder.model' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) @@ -368,10 +369,11 @@ async function removeVideoFromPlaylist (req: express.Request, res: express.Respo async function reorderVideosPlaylist (req: express.Request, res: express.Response) { const videoPlaylist: VideoPlaylistModel = res.locals.videoPlaylist + const body: VideoPlaylistReorder = req.body - const start: number = req.body.startPosition - const insertAfter: number = req.body.insertAfterPosition - const reorderLength: number = req.body.reorderLength || 1 + const start: number = body.startPosition + const insertAfter: number = body.insertAfterPosition + const reorderLength: number = body.reorderLength || 1 if (start === insertAfter) { return res.status(204).end() diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 06c63e87c..7624b0649 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -240,7 +240,10 @@ type AvailableForListIDsOptions = { if (options.videoPlaylistId) { query.include.push({ model: VideoPlaylistElementModel.unscoped(), - required: true + required: true, + where: { + videoPlaylistId: options.videoPlaylistId + } }) } @@ -304,6 +307,8 @@ type AvailableForListIDsOptions = { videoPlaylistId: options.videoPlaylistId } }) + + query.subQuery = false } if (options.filter || options.accountId || options.videoChannelId) { -- cgit v1.2.3