mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
move some code
This commit is contained in:
@@ -724,10 +724,22 @@ export class Subsonic {
|
||||
)
|
||||
);
|
||||
|
||||
// getStarred2 = (credentials: Credentials): Promise<{ albums: Album[] }> =>
|
||||
// this.getJSON<GetStarredResponse>(credentials, "/rest/getStarred2")
|
||||
// .then((it) => it.starred2)
|
||||
// .then((it) => ({
|
||||
// albums: it.album.map(asAlbum),
|
||||
// }));
|
||||
private st4r = (credentials: Credentials, action: string, { id } : { id: string }) =>
|
||||
this.getJSON<SubsonicResponse>(credentials, `/rest/${action}`, { id }).then(it =>
|
||||
it.status == "ok"
|
||||
);
|
||||
|
||||
star = (credentials: Credentials, ids : { id: string }) =>
|
||||
this.st4r(credentials, "star", ids)
|
||||
|
||||
unstar = (credentials: Credentials, ids : { id: string }) =>
|
||||
this.st4r(credentials, "unstar", ids)
|
||||
|
||||
setRating = (credentials: Credentials, id: string, rating: number) =>
|
||||
this.getJSON<SubsonicResponse>(credentials, `/rest/setRating`, {
|
||||
id,
|
||||
rating,
|
||||
}).then(it =>
|
||||
it.status == "ok"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -191,21 +191,12 @@ export class SubsonicMusicLibrary implements MusicLibrary {
|
||||
const thingsToUpdate = [];
|
||||
if (track.rating.love != rating.love) {
|
||||
thingsToUpdate.push(
|
||||
this.subsonic.getJSON(
|
||||
this.credentials,
|
||||
`/rest/${rating.love ? "star" : "unstar"}`,
|
||||
{
|
||||
id: trackId,
|
||||
}
|
||||
)
|
||||
(rating.love ? this.subsonic.star : this.subsonic.unstar)(this.credentials,{ id: trackId })
|
||||
);
|
||||
}
|
||||
if (track.rating.stars != rating.stars) {
|
||||
thingsToUpdate.push(
|
||||
this.subsonic.getJSON(this.credentials, `/rest/setRating`, {
|
||||
id: trackId,
|
||||
rating: rating.stars,
|
||||
})
|
||||
this.subsonic.setRating(this.credentials, trackId, rating.stars)
|
||||
);
|
||||
}
|
||||
return Promise.all(thingsToUpdate);
|
||||
|
||||
Reference in New Issue
Block a user