Add archive all button in inbox (#4870)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2024-03-05 02:31:45 +07:00
committed by GitHub
parent 1847ae6aaa
commit 423d6f044a
6 changed files with 39 additions and 8 deletions
@@ -20,7 +20,8 @@ import {
type Doc,
type Ref,
type TxOperations,
type WithLookup
type WithLookup,
generateId
} from '@hcengineering/core'
import notification, {
type ActivityInboxNotification,
@@ -29,7 +30,7 @@ import notification, {
type InboxNotification,
type InboxNotificationsClient
} from '@hcengineering/notification'
import { createQuery } from '@hcengineering/presentation'
import { createQuery, getClient } from '@hcengineering/presentation'
import { derived, get, writable } from 'svelte/store'
export const inboxMessagesStore = writable<ActivityMessage[]>([])
@@ -250,4 +251,19 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
await client.remove(notification)
}
}
async deleteAllNotifications (): Promise<void> {
const doneOp = await getClient().measure('deleteAllNotifications')
const ops = getClient().apply(generateId())
try {
const inboxNotifications = get(this.inboxNotifications) ?? []
for (const notification of inboxNotifications) {
await ops.remove(notification)
}
} finally {
await ops.commit()
await doneOp()
}
}
}