Skip to content

Commit

Permalink
Fix bug where deleting items does not reduce the inbox counter
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Feb 28, 2024
1 parent 08ecdfe commit 60811b5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/dashboard-refactor/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,21 @@ export class DashboardLogic extends UILogic<State, Events> {
previousState,
}) => {
if (event.instaDelete) {
const pageLists =
previousState.searchResults.pageData.byId[event.pageId].lists
const isPageInInbox = pageLists.some(
(listId) =>
this.options.annotationsCache.lists.byId[listId].localId ===
SPECIAL_LIST_IDS.INBOX,
)

if (isPageInInbox) {
this.emitMutation({
listsSidebar: {
inboxUnreadCount: { $apply: (count) => count - 1 },
},
})
}
await executeUITask(
this,
(taskState) => ({
Expand Down Expand Up @@ -1808,6 +1823,20 @@ export class DashboardLogic extends UILogic<State, Events> {

const { pageId, day } = modals.deletingPageArgs

const pageLists = pageData.byId[pageId].lists
const isPageInInbox = pageLists.some(
(listId) =>
this.options.annotationsCache.lists.byId[listId].localId ===
SPECIAL_LIST_IDS.INBOX,
)

if (isPageInInbox) {
this.emitMutation({
listsSidebar: {
inboxUnreadCount: { $apply: (count) => count - 1 },
},
})
}
await executeUITask(
this,
(taskState) => ({
Expand Down

0 comments on commit 60811b5

Please sign in to comment.