mirror of
https://github.com/jeffvli/sonixd.git
synced 2026-04-30 11:12:36 -04:00
Add batch star
This commit is contained in:
@@ -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 } }));
|
||||
}
|
||||
|
||||
@@ -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 } },
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user