Create global inbox actions (#4903)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2024-03-08 14:59:20 +07:00
committed by GitHub
parent 0483e2ac0d
commit 5ce079cf3d
11 changed files with 172 additions and 43 deletions
@@ -283,4 +283,21 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
await doneOp()
}
}
async unreadAllNotifications (): Promise<void> {
const doneOp = await getClient().measure('unreadAllNotifications')
const ops = getClient().apply(generateId())
try {
const inboxNotifications = get(this.inboxNotifications) ?? []
for (const notification of inboxNotifications) {
if (notification.isViewed) {
await ops.update(notification, { isViewed: false })
}
}
} finally {
await ops.commit()
await doneOp()
}
}
}