feat: context menu for watchhistory items

This commit is contained in:
Adrian Castro
2024-03-27 13:08:56 +01:00
parent 1e653e6540
commit dca49e8563
2 changed files with 23 additions and 1 deletions

View File

@@ -141,6 +141,7 @@ interface WatchHistoryItem {
interface WatchHistoryStoreState {
watchHistory: WatchHistoryItem[];
hasWatchHistoryItem: (item: ItemData) => boolean;
getWatchHistorItem: (media: ScrapeMedia) => WatchHistoryItem | undefined;
setWatchHistory: (watchHistory: WatchHistoryItem[]) => void;
updateWatchHistory: (
@@ -158,6 +159,12 @@ export const useWatchHistoryStore = create<
persist(
(set, get) => ({
watchHistory: [],
hasWatchHistoryItem: (item: ItemData) =>
Boolean(
get().watchHistory.find(
(historyItem) => historyItem.item.id === item.id,
),
),
getWatchHistorItem: (media: ScrapeMedia) =>
get().watchHistory.find((historyItem) => {
if (historyItem.media.type === "movie" && media.type === "movie") {