Add methods to directly set progress and bookmark items

This commit is contained in:
William Oldham 2024-03-16 17:50:24 +00:00
parent 558c6431fd
commit a642abc783
2 changed files with 12 additions and 0 deletions

View File

@ -26,6 +26,7 @@ export interface BookmarkStore {
bookmarks: Record<string, BookmarkMediaItem>;
updateQueue: BookmarkUpdateItem[];
addBookmark(meta: PlayerMeta): void;
setBookmark(id: string, item: BookmarkMediaItem): void;
removeBookmark(id: string): void;
replaceBookmarks(items: Record<string, BookmarkMediaItem>): void;
clear(): void;
@ -94,6 +95,11 @@ export const useBookmarkStore = create(
s.updateQueue = [...s.updateQueue.filter((v) => v.id !== id)];
});
},
setBookmark(id, item) {
set((s) => {
s.bookmarks[id] = item;
});
},
})),
{
name: "__MW::bookmarks",

View File

@ -64,6 +64,7 @@ export interface ProgressStore {
clear(): void;
clearUpdateQueue(): void;
removeUpdateItem(id: string): void;
setItem(id: string, item: ProgressMediaItem): void;
}
let updateId = 0;
@ -173,6 +174,11 @@ export const useProgressStore = create(
s.updateQueue = [...s.updateQueue.filter((v) => v.id !== id)];
});
},
setItem(id, item) {
set((s) => {
s.items[id] = item;
});
},
})),
{
name: "__MW::progress",