From 09ccd39496fde70be950c711b1eb1230395fbd7d Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Mon, 24 Feb 2025 23:30:37 +0800 Subject: [PATCH] fix(mobile): read state not updated after mark view as read (#2875) --- apps/mobile/src/store/unread/store.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/mobile/src/store/unread/store.ts b/apps/mobile/src/store/unread/store.ts index 49ab0cc24..a135c99ca 100644 --- a/apps/mobile/src/store/unread/store.ts +++ b/apps/mobile/src/store/unread/store.ts @@ -30,6 +30,15 @@ class UnreadSyncService { return res.data } + private async updateUnreadStatus(feedIds: string[]) { + await unreadActions.upsertMany(feedIds.map((id) => ({ subscriptionId: id, count: 0 }))) + entryActions.markEntryReadStatusInSession({ feedIds, read: true }) + await EntryService.patchMany({ + feedIds, + entry: { read: true }, + }) + } + async markViewAsRead(view: FeedViewType) { await apiClient.reads.all.$post({ json: { @@ -38,7 +47,7 @@ class UnreadSyncService { }) const subscriptionIds = getSubscriptionByView(view) - await unreadActions.upsertMany(subscriptionIds.map((id) => ({ subscriptionId: id, count: 0 }))) + this.updateUnreadStatus(subscriptionIds) } async markFeedAsRead(feedId: string | string[]) { @@ -48,12 +57,7 @@ class UnreadSyncService { json: { feedIdList: feedIds }, }) - await unreadActions.upsertMany(feedIds.map((id) => ({ subscriptionId: id, count: 0 }))) - entryActions.markEntryReadStatusInSession({ feedIds, read: true }) - await EntryService.patchMany({ - feedIds, - entry: { read: true }, - }) + this.updateUnreadStatus(feedIds) } async markEntryAsRead(entryId: string) {