Skip to content

Commit

Permalink
fix(mobile): update types and star entry with view
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs committed Feb 12, 2025
1 parent db5bd26 commit 5a6c9e6
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions apps/mobile/src/modules/context-menu/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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")
}
}}
Expand Down

0 comments on commit 5a6c9e6

Please sign in to comment.