From 5a6c9e619ac31aed1d88fce935796df38e98fd7f Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Wed, 12 Feb 2025 15:16:22 +0800 Subject: [PATCH] fix(mobile): update types and star entry with view --- .../mobile/src/modules/context-menu/entry.tsx | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/apps/mobile/src/modules/context-menu/entry.tsx b/apps/mobile/src/modules/context-menu/entry.tsx index bdea0258cc..6e30eb1ece 100644 --- a/apps/mobile/src/modules/context-menu/entry.tsx +++ b/apps/mobile/src/modules/context-menu/entry.tsx @@ -16,8 +16,11 @@ import { collectionSyncService } from "@/src/store/collection/store" import { useEntry } from "@/src/store/entry/hooks" import { unreadSyncService } from "@/src/store/unread/store" +import { useSelectedView } from "../feed-drawer/atoms" + export const EntryItemContextMenu = ({ id, children }: PropsWithChildren<{ id: string }>) => { const entry = useEntry(id) + const view = useSelectedView() const isEntryStarred = useIsEntryStarred(id) const handlePressPreview = useCallback(() => { @@ -59,24 +62,18 @@ export const EntryItemContextMenu = ({ id, children }: PropsWithChildren<{ id: s key="Star" onSelect={() => { if (isEntryStarred) { - collectionSyncService.unstarEntry({ - createdAt: new Date().toISOString(), + collectionSyncService.unstarEntry(id) + toast.info("Unstarred") + } else { + if (!entry.feedId || view === undefined) { + console.error("Failed to star entry", view, entry.feedId, entry) + return + } + collectionSyncService.starEntry({ feedId: entry.feedId, entryId: id, - view: 0, + view, }) - toast.info("Unstarred") - } else { - collectionSyncService.starEntry( - { - createdAt: new Date().toISOString(), - feedId: entry.feedId, - entryId: id, - // TODO update view - view: 0, - }, - 0, - ) toast.info("Starred") } }}