feat(mobile): mark as unread in menu
This commit is contained in:
@@ -61,13 +61,17 @@ export const EntryItemContextMenu = ({ id, children }: PropsWithChildren<{ id: s
|
||||
<ContextMenu.Item
|
||||
key="MarkAsRead"
|
||||
onSelect={() => {
|
||||
unreadSyncService.markEntryAsRead(id)
|
||||
entry.read
|
||||
? unreadSyncService.markEntryAsUnread(id)
|
||||
: unreadSyncService.markEntryAsRead(id)
|
||||
}}
|
||||
>
|
||||
<ContextMenu.ItemTitle>{t("operation.mark_as_read")}</ContextMenu.ItemTitle>
|
||||
<ContextMenu.ItemTitle>
|
||||
{entry.read ? t("operation.mark_as_unread") : t("operation.mark_as_read")}
|
||||
</ContextMenu.ItemTitle>
|
||||
<ContextMenu.ItemIcon
|
||||
ios={{
|
||||
name: "checkmark",
|
||||
name: entry.read ? "circle.fill" : "circle",
|
||||
}}
|
||||
/>
|
||||
</ContextMenu.Item>
|
||||
|
||||
@@ -97,6 +97,44 @@ class UnreadSyncService {
|
||||
|
||||
await tx.run()
|
||||
}
|
||||
|
||||
async markEntryAsUnread(entryId: string) {
|
||||
const entry = getEntry(entryId)
|
||||
if (!entry || !entry?.read) return
|
||||
|
||||
const feedId = entry?.feedId
|
||||
|
||||
const tx = createTransaction()
|
||||
tx.store(() => {
|
||||
entryActions.markEntryReadStatusInSession({ entryIds: [entryId], read: false })
|
||||
|
||||
if (feedId) {
|
||||
unreadActions.addUnread(feedId)
|
||||
}
|
||||
})
|
||||
tx.rollback(() => {
|
||||
entryActions.markEntryReadStatusInSession({ entryIds: [entryId], read: true })
|
||||
|
||||
if (feedId) {
|
||||
unreadActions.removeUnread(feedId)
|
||||
}
|
||||
})
|
||||
|
||||
tx.request(() => {
|
||||
apiClient.reads.$delete({
|
||||
json: { entryId },
|
||||
})
|
||||
})
|
||||
|
||||
tx.persist(() => {
|
||||
return EntryService.patchMany({
|
||||
entry: { read: false },
|
||||
entryIds: [entryId],
|
||||
})
|
||||
})
|
||||
|
||||
await tx.run()
|
||||
}
|
||||
}
|
||||
|
||||
class UnreadActions {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"operation.mark_all_as_read_which": "Mark {{which}} as read",
|
||||
"operation.mark_all_as_read_which_above": "above",
|
||||
"operation.mark_as_read": "Mark as Read",
|
||||
"operation.mark_as_unread": "Mark as Unread",
|
||||
"operation.open_link": "Open Link",
|
||||
"operation.rename_category": "Rename Category",
|
||||
"operation.share": "Share",
|
||||
|
||||
Reference in New Issue
Block a user