Fix JF playlist controller

This commit is contained in:
jeffvli 2023-05-21 18:19:02 -07:00
parent 098e86b1f4
commit 64c5f25d18
2 changed files with 12 additions and 9 deletions

View file

@ -6,16 +6,18 @@ import qs from 'qs';
import { toast } from '/@/renderer/components'; import { toast } from '/@/renderer/components';
import { ServerListItem } from '/@/renderer/types'; import { ServerListItem } from '/@/renderer/types';
import omitBy from 'lodash/omitBy'; import omitBy from 'lodash/omitBy';
import { z } from 'zod';
const c = initContract(); const c = initContract();
export const contract = c.router({ export const contract = c.router({
addToPlaylist: { addToPlaylist: {
body: jfType._parameters.addToPlaylist, body: z.null(),
method: 'POST', method: 'POST',
path: 'playlists/:id/items', path: 'playlists/:id/items',
query: jfType._parameters.addToPlaylist,
responses: { responses: {
200: jfType._response.addToPlaylist, 204: jfType._response.addToPlaylist,
400: jfType._response.error, 400: jfType._response.error,
}, },
}, },
@ -190,7 +192,7 @@ export const contract = c.router({
removeFromPlaylist: { removeFromPlaylist: {
body: null, body: null,
method: 'DELETE', method: 'DELETE',
path: 'items/:id', path: 'playlists/:id/items',
query: jfType._parameters.removeFromPlaylist, query: jfType._parameters.removeFromPlaylist,
responses: { responses: {
200: jfType._response.removeFromPlaylist, 200: jfType._response.removeFromPlaylist,

View file

@ -403,16 +403,17 @@ const addToPlaylist = async (args: AddToPlaylistArgs): Promise<AddToPlaylistResp
} }
const res = await jfApiClient(apiClientProps).addToPlaylist({ const res = await jfApiClient(apiClientProps).addToPlaylist({
body: { body: null,
Ids: body.songId,
UserId: apiClientProps?.server?.userId,
},
params: { params: {
id: query.id, 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'); 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'); throw new Error('Failed to remove from playlist');
} }