enable reordering non-smart playlists

This commit is contained in:
Kendall Garner 2024-08-25 15:21:56 -07:00
parent 0b383b758e
commit 10fca2dc12
No known key found for this signature in database
GPG key ID: 18D2767419676C87
11 changed files with 148 additions and 0 deletions

View file

@ -226,6 +226,15 @@ export const contract = c.router({
400: jfType._response.error,
},
},
movePlaylistItem: {
body: null,
method: 'POST',
path: 'playlists/:playlistId/items/:itemId/move/:newIdx',
responses: {
200: jfType._response.moveItem,
400: jfType._response.error,
},
},
removeFavorite: {
body: jfType._parameters.favorite,
method: 'DELETE',

View file

@ -53,6 +53,7 @@ import {
ServerInfoArgs,
SimilarSongsArgs,
Song,
MoveItemArgs,
} from '/@/renderer/api/types';
import { jfApiClient } from '/@/renderer/api/jellyfin/jellyfin-api';
import { jfNormalize } from './jellyfin-normalize';
@ -1025,6 +1026,23 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise<Song[]> => {
}, []);
};
const movePlaylistItem = async (args: MoveItemArgs): Promise<void> => {
const { apiClientProps, query } = args;
const res = await jfApiClient(apiClientProps).movePlaylistItem({
body: null,
params: {
itemId: query.trackId,
newIdx: query.endingIndex.toString(),
playlistId: query.playlistId,
},
});
if (res.status !== 204) {
throw new Error('Failed to move item in playlist');
}
};
export const jfController = {
addToPlaylist,
authenticate,
@ -1049,6 +1067,7 @@ export const jfController = {
getSongDetail,
getSongList,
getTopSongList,
movePlaylistItem,
removeFromPlaylist,
scrobble,
search,

View file

@ -681,6 +681,8 @@ export enum JellyfinExtensions {
SONG_LYRICS = 'songLyrics',
}
const moveItem = z.null();
export const jfType = {
_enum: {
albumArtistList: albumArtistListSort,
@ -729,6 +731,7 @@ export const jfType = {
genre,
genreList,
lyrics,
moveItem,
musicFolderList,
playlist,
playlistList,