Skip to content

Commit

Permalink
feat: inbox unread data updating
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Oct 3, 2024
1 parent edbdc86 commit 61d9a48
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 7 additions & 1 deletion apps/renderer/src/modules/entry-column/hooks/useMarkAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface MarkAllFilter {
}
export const useMarkAllByRoute = (filter?: MarkAllFilter) => {
const routerParams = useRouteParams()
const { feedId, view } = routerParams
const { feedId, view, inboxId } = routerParams
const folderIds = useFolderFeedsByFeedId({
feedId,
view,
Expand All @@ -21,6 +21,12 @@ export const useMarkAllByRoute = (filter?: MarkAllFilter) => {

if (typeof routerParams.feedId === "number" || routerParams.isAllFeeds) {
subscriptionActions.markReadByView(view, filter)
} else if (inboxId) {
subscriptionActions.markReadByFeedIds({
inboxId,
view,
filter,
})
} else if (folderIds) {
subscriptionActions.markReadByFeedIds({
feedIds: folderIds,
Expand Down
15 changes: 12 additions & 3 deletions apps/renderer/src/store/subscription/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,13 @@ class SubscriptionActions {

async markReadByFeedIds({
feedIds,
inboxId,
view,
filter,
listId,
}: {
feedIds?: string[]
inboxId?: string
view?: FeedViewType
filter?: MarkReadFilter
listId?: string
Expand All @@ -244,15 +246,22 @@ class SubscriptionActions {
? {
listId,
}
: {
feedIdList: stableFeedIds,
}),
: inboxId
? {
inboxId,
}
: {
feedIdList: stableFeedIds,
}),
...filter,
},
}),
async () => {
if (listId) {
feedUnreadActions.updateByFeedId(listId, 0)
} else if (inboxId) {
feedUnreadActions.updateByFeedId(inboxId, 0)
entryActions.patchManyByFeedId(inboxId, { read: true }, filter)
} else {
for (const feedId of stableFeedIds) {
// We can not process this logic in local, so skip it. and then we will fetch the unread count from server.
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5086,6 +5086,7 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
view?: number | undefined;
feedIdList?: string[] | undefined;
feedId?: string | undefined;
inboxId?: string | undefined;
listId?: string | undefined;
startTime?: number | undefined;
endTime?: number | undefined;
Expand Down

0 comments on commit 61d9a48

Please sign in to comment.