Add batch star

This commit is contained in:
jeffvli
2021-11-19 20:18:21 -08:00
committed by Jeff
parent 4577540584
commit 5ea1358e52
3 changed files with 26 additions and 4 deletions

View File

@@ -411,8 +411,6 @@ export const getArtistSongs = async (options: { id: string }) => {
const promises = [];
const { data } = await api.get(`/getArtist`, { params: options });
console.log(`artist`, data.artist);
for (let i = 0; i < data.artist.album.length; i += 1) {
promises.push(api.get(`/getAlbum`, { params: { id: data.artist.album[i].id } }));
}

View File

@@ -44,6 +44,8 @@ import {
getStarred as jfGetStarred,
star as jfStar,
unstar as jfUnstar,
batchStar as jfBatchStar,
batchUnstar as jfBatchUnstar,
} from './jellyfinApi';
import { APIEndpoints, ServerType } from '../types';
@@ -62,8 +64,8 @@ const endpoints = [
{ id: 'getScanStatus', endpoint: { subsonic: getScanStatus, jellyfin: undefined } },
{ id: 'star', endpoint: { subsonic: star, jellyfin: jfStar } },
{ id: 'unstar', endpoint: { subsonic: unstar, jellyfin: jfUnstar } },
{ id: 'batchStar', endpoint: { subsonic: batchStar, jellyfin: undefined } },
{ id: 'batchUnstar', endpoint: { subsonic: batchUnstar, jellyfin: undefined } },
{ id: 'batchStar', endpoint: { subsonic: batchStar, jellyfin: jfBatchStar } },
{ id: 'batchUnstar', endpoint: { subsonic: batchUnstar, jellyfin: jfBatchUnstar } },
{ id: 'setRating', endpoint: { subsonic: setRating, jellyfin: undefined } },
{ id: 'getSimilarSongs', endpoint: { subsonic: getSimilarSongs, jellyfin: undefined } },
{ id: 'updatePlaylistSongs', endpoint: { subsonic: updatePlaylistSongs, jellyfin: undefined } },

View File

@@ -387,3 +387,25 @@ export const unstar = async (options: { id: string }) => {
const { data } = await jellyfinApi.delete(`/users/${auth.username}/favoriteitems/${options.id}`);
return data;
};
export const batchStar = async (options: { ids: string[] }) => {
const promises = [];
for (let i = 0; i < options.ids.length; i += 1) {
promises.push(star({ id: options.ids[i] }));
}
const res = await Promise.all(promises);
return res;
};
export const batchUnstar = async (options: { ids: string[] }) => {
const promises = [];
for (let i = 0; i < options.ids.length; i += 1) {
promises.push(unstar({ id: options.ids[i] }));
}
const res = await Promise.all(promises);
return res;
};