Browse Source

update playlist endpoints

master
jeffvli 3 years ago
parent
commit
f53f310387
  1. 17
      src/api/api.ts
  2. 2
      src/components/playlist/PlaylistList.tsx

17
src/api/api.ts

@ -120,6 +120,16 @@ export const getPlaylists = async (sortBy: string) => {
? data.playlists?.playlist.sort((a: any, b: any) => {
return a.changed > b.changed ? -1 : a.changed < b.changed ? 1 : 0;
})
: sortBy === 'name'
? data.playlists?.playlist.sort((a: any, b: any) => {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
})
: data.playlists?.playlist;
return (newData || []).map((playlist: any) => ({
@ -499,6 +509,7 @@ export const populatePlaylist = async (id: string, entry: any[]) => {
// Set these in chunks so the api doesn't break
const entryIdChunks = _.chunk(entryIds, 325);
let data;
for (let i = 0; i < entryIdChunks.length; i += 1) {
const params = new URLSearchParams();
@ -511,8 +522,12 @@ export const populatePlaylist = async (id: string, entry: any[]) => {
params.append('songIdToAdd', String(entryIdChunks[i][x]));
}
data = (
await playlistApi.get(`/updatePlaylist`, {
params,
});
})
).data;
}
return data;
};

2
src/components/playlist/PlaylistList.tsx

@ -13,7 +13,7 @@ import GridViewType from '../viewtypes/GridViewType';
const PlaylistList = () => {
const history = useHistory();
const [sortBy] = useState('');
const [sortBy] = useState('name');
const [viewType, setViewType] = useState(
settings.getSync('playlistViewType') || 'list'
);

Loading…
Cancel
Save