Finish Favorites UI and jumping
This commit is contained in:
@@ -61,6 +61,16 @@ export const API = {
|
||||
body: JSON.stringify({ url }),
|
||||
});
|
||||
},
|
||||
|
||||
async replaceCurrentFile(url: string): Promise<void> {
|
||||
await fetch('/api/playlist/replace', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ url }),
|
||||
});
|
||||
},
|
||||
|
||||
async removeFromPlaylist(index: number): Promise<void> {
|
||||
await fetch(`/api/playlist/${index}`, {
|
||||
@@ -116,5 +126,38 @@ export const API = {
|
||||
};
|
||||
|
||||
return ws;
|
||||
},
|
||||
|
||||
async getFavorites(): Promise<PlaylistItem[]> {
|
||||
const response = await fetch('/api/favorites');
|
||||
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,
|
||||
};
|
||||
|
||||
await fetch('/api/favorites', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(playlistItem),
|
||||
});
|
||||
},
|
||||
|
||||
async removeFromFavorites(id: number): Promise<void> {
|
||||
await fetch(`/api/favorites/${id}`, { method: 'DELETE' });
|
||||
},
|
||||
|
||||
async clearFavorites(): Promise<void> {
|
||||
await fetch('/api/favorites', { method: 'DELETE' });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user