Adds add to favorites button in SongRow
This commit is contained in:
@@ -142,28 +142,18 @@ export const API = {
|
||||
return response.json();
|
||||
},
|
||||
|
||||
async addToFavorites(url: string): Promise<void> {
|
||||
// Maybe a little weird to make an empty PlaylistItem here, but we do want to support adding
|
||||
// known PlaylistItems to favorites in the future.
|
||||
const playlistItem: PlaylistItem = {
|
||||
filename: url,
|
||||
title: null,
|
||||
id: 0,
|
||||
playing: null,
|
||||
metadata: undefined,
|
||||
};
|
||||
|
||||
async addToFavorites(filename: string): Promise<void> {
|
||||
await fetch('/api/favorites', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(playlistItem),
|
||||
body: JSON.stringify({ filename }),
|
||||
});
|
||||
},
|
||||
|
||||
async removeFromFavorites(id: number): Promise<void> {
|
||||
await fetch(`/api/favorites/${id}`, { method: 'DELETE' });
|
||||
async removeFromFavorites(filename: string): Promise<void> {
|
||||
await fetch(`/api/favorites/${encodeURIComponent(filename)}`, { method: 'DELETE' });
|
||||
},
|
||||
|
||||
async clearFavorites(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user