From a642abc78351f77b5d623585002033c56688653c Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sat, 16 Mar 2024 17:50:24 +0000 Subject: [PATCH] Add methods to directly set progress and bookmark items --- src/stores/bookmarks/index.ts | 6 ++++++ src/stores/progress/index.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/stores/bookmarks/index.ts b/src/stores/bookmarks/index.ts index 7d4787be..25fbd8cd 100644 --- a/src/stores/bookmarks/index.ts +++ b/src/stores/bookmarks/index.ts @@ -26,6 +26,7 @@ export interface BookmarkStore { bookmarks: Record; updateQueue: BookmarkUpdateItem[]; addBookmark(meta: PlayerMeta): void; + setBookmark(id: string, item: BookmarkMediaItem): void; removeBookmark(id: string): void; replaceBookmarks(items: Record): 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", diff --git a/src/stores/progress/index.ts b/src/stores/progress/index.ts index a209658f..df14d741 100644 --- a/src/stores/progress/index.ts +++ b/src/stores/progress/index.ts @@ -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",