mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 05:13:06 +00:00
Add archive all button in inbox (#4870)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
1847ae6aaa
commit
423d6f044a
@ -35,6 +35,7 @@
|
|||||||
"Pinned": "Pinned",
|
"Pinned": "Pinned",
|
||||||
"Message": "Message",
|
"Message": "Message",
|
||||||
"FlatList": "Flat list",
|
"FlatList": "Flat list",
|
||||||
"GroupedList": "Grouped list"
|
"GroupedList": "Grouped list",
|
||||||
|
"ArchiveAll": "Archive all"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"Pinned": "Закреплено",
|
"Pinned": "Закреплено",
|
||||||
"Message": "Сообщение",
|
"Message": "Сообщение",
|
||||||
"FlatList": "Flat list",
|
"FlatList": "Flat list",
|
||||||
"GroupedList": "Grouped list"
|
"GroupedList": "Grouped list",
|
||||||
|
"ArchiveAll": "Архивировать все"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Button, IconFilter, SelectPopup, eventToHTMLElement, showPopup } from '@hcengineering/ui'
|
import { IconFilter, SelectPopup, eventToHTMLElement, showPopup, ButtonIcon } from '@hcengineering/ui'
|
||||||
import notification from '../plugin'
|
import notification from '../plugin'
|
||||||
|
|
||||||
export let filter: 'all' | 'read' | 'unread' = 'all'
|
export let filter: 'all' | 'read' | 'unread' = 'all'
|
||||||
@ -45,4 +45,4 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button icon={IconFilter} on:click={click} />
|
<ButtonIcon icon={IconFilter} size="small" on:click={click} />
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
Separator,
|
Separator,
|
||||||
TabItem,
|
TabItem,
|
||||||
TabList,
|
TabList,
|
||||||
Location
|
Location,
|
||||||
|
ModernButton
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import chunter, { ThreadMessage } from '@hcengineering/chunter'
|
import chunter, { ThreadMessage } from '@hcengineering/chunter'
|
||||||
import { Ref, WithLookup } from '@hcengineering/core'
|
import { Ref, WithLookup } from '@hcengineering/core'
|
||||||
@ -255,6 +256,10 @@
|
|||||||
onMount(() => {
|
onMount(() => {
|
||||||
loadSavedMessages()
|
loadSavedMessages()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function archiveAll (): void {
|
||||||
|
void inboxClient.deleteAllNotifications()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ActionContext
|
<ActionContext
|
||||||
@ -283,6 +288,12 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-gap-2">
|
<div class="flex flex-gap-2">
|
||||||
|
<ModernButton
|
||||||
|
label={notification.string.ArchiveAll}
|
||||||
|
icon={view.icon.Archive}
|
||||||
|
size="small"
|
||||||
|
on:click={archiveAll}
|
||||||
|
/>
|
||||||
<Filter bind:filter />
|
<Filter bind:filter />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -20,7 +20,8 @@ import {
|
|||||||
type Doc,
|
type Doc,
|
||||||
type Ref,
|
type Ref,
|
||||||
type TxOperations,
|
type TxOperations,
|
||||||
type WithLookup
|
type WithLookup,
|
||||||
|
generateId
|
||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import notification, {
|
import notification, {
|
||||||
type ActivityInboxNotification,
|
type ActivityInboxNotification,
|
||||||
@ -29,7 +30,7 @@ import notification, {
|
|||||||
type InboxNotification,
|
type InboxNotification,
|
||||||
type InboxNotificationsClient
|
type InboxNotificationsClient
|
||||||
} from '@hcengineering/notification'
|
} from '@hcengineering/notification'
|
||||||
import { createQuery } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { derived, get, writable } from 'svelte/store'
|
import { derived, get, writable } from 'svelte/store'
|
||||||
|
|
||||||
export const inboxMessagesStore = writable<ActivityMessage[]>([])
|
export const inboxMessagesStore = writable<ActivityMessage[]>([])
|
||||||
@ -250,4 +251,19 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
await client.remove(notification)
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,6 +282,7 @@ export interface InboxNotificationsClient {
|
|||||||
readNotifications: (client: TxOperations, ids: Array<Ref<InboxNotification>>) => Promise<void>
|
readNotifications: (client: TxOperations, ids: Array<Ref<InboxNotification>>) => Promise<void>
|
||||||
unreadNotifications: (client: TxOperations, ids: Array<Ref<InboxNotification>>) => Promise<void>
|
unreadNotifications: (client: TxOperations, ids: Array<Ref<InboxNotification>>) => Promise<void>
|
||||||
deleteNotifications: (client: TxOperations, ids: Array<Ref<InboxNotification>>) => Promise<void>
|
deleteNotifications: (client: TxOperations, ids: Array<Ref<InboxNotification>>) => Promise<void>
|
||||||
|
deleteAllNotifications: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -388,7 +389,8 @@ const notification = plugin(notificationId, {
|
|||||||
Pinned: '' as IntlString,
|
Pinned: '' as IntlString,
|
||||||
FlatList: '' as IntlString,
|
FlatList: '' as IntlString,
|
||||||
GroupedList: '' as IntlString,
|
GroupedList: '' as IntlString,
|
||||||
All: '' as IntlString
|
All: '' as IntlString,
|
||||||
|
ArchiveAll: '' as IntlString
|
||||||
},
|
},
|
||||||
function: {
|
function: {
|
||||||
GetInboxNotificationsClient: '' as Resource<InboxNotificationsClientFactory>,
|
GetInboxNotificationsClient: '' as Resource<InboxNotificationsClientFactory>,
|
||||||
|
Loading…
Reference in New Issue
Block a user