Fix JF playlist controller
This commit is contained in:
parent
098e86b1f4
commit
64c5f25d18
2 changed files with 12 additions and 9 deletions
|
@ -6,16 +6,18 @@ import qs from 'qs';
|
|||
import { toast } from '/@/renderer/components';
|
||||
import { ServerListItem } from '/@/renderer/types';
|
||||
import omitBy from 'lodash/omitBy';
|
||||
import { z } from 'zod';
|
||||
|
||||
const c = initContract();
|
||||
|
||||
export const contract = c.router({
|
||||
addToPlaylist: {
|
||||
body: jfType._parameters.addToPlaylist,
|
||||
body: z.null(),
|
||||
method: 'POST',
|
||||
path: 'playlists/:id/items',
|
||||
query: jfType._parameters.addToPlaylist,
|
||||
responses: {
|
||||
200: jfType._response.addToPlaylist,
|
||||
204: jfType._response.addToPlaylist,
|
||||
400: jfType._response.error,
|
||||
},
|
||||
},
|
||||
|
@ -190,7 +192,7 @@ export const contract = c.router({
|
|||
removeFromPlaylist: {
|
||||
body: null,
|
||||
method: 'DELETE',
|
||||
path: 'items/:id',
|
||||
path: 'playlists/:id/items',
|
||||
query: jfType._parameters.removeFromPlaylist,
|
||||
responses: {
|
||||
200: jfType._response.removeFromPlaylist,
|
||||
|
|
|
@ -403,16 +403,17 @@ const addToPlaylist = async (args: AddToPlaylistArgs): Promise<AddToPlaylistResp
|
|||
}
|
||||
|
||||
const res = await jfApiClient(apiClientProps).addToPlaylist({
|
||||
body: {
|
||||
Ids: body.songId,
|
||||
UserId: apiClientProps?.server?.userId,
|
||||
},
|
||||
body: null,
|
||||
params: {
|
||||
id: query.id,
|
||||
},
|
||||
query: {
|
||||
Ids: body.songId,
|
||||
UserId: apiClientProps.server?.userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
if (res.status !== 204) {
|
||||
throw new Error('Failed to add to playlist');
|
||||
}
|
||||
|
||||
|
@ -434,7 +435,7 @@ const removeFromPlaylist = async (
|
|||
},
|
||||
});
|
||||
|
||||
if (res.status !== 200) {
|
||||
if (res.status !== 204) {
|
||||
throw new Error('Failed to remove from playlist');
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue