diff --git a/plugins/activity-resources/src/activityMessagesUtils.ts b/plugins/activity-resources/src/activityMessagesUtils.ts index 3b5ff95965..4da35164e3 100644 --- a/plugins/activity-resources/src/activityMessagesUtils.ts +++ b/plugins/activity-resources/src/activityMessagesUtils.ts @@ -594,3 +594,11 @@ export function isReactionMessage (message?: ActivityMessage): boolean { return message.objectClass === activity.class.Reaction } + +export function isActivityMessageClass (_class?: Ref>): boolean { + if (_class === undefined) { + return false + } + + return getClient().getHierarchy().isDerived(_class, activity.class.ActivityMessage) +} diff --git a/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte b/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte index afa11835f2..08d6d154b6 100644 --- a/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte +++ b/plugins/chunter-resources/src/components/chat/navigator/ChatNavItem.svelte @@ -18,7 +18,12 @@ import { getClient } from '@hcengineering/presentation' import { Action, IconEdit } from '@hcengineering/ui' import { getActions } from '@hcengineering/view-resources' - import { getNotificationsCount, InboxNotificationsClientImpl } from '@hcengineering/notification-resources' + import { + getNotificationsCount, + InboxNotificationsClientImpl, + isActivityNotification, + isMentionNotification + } from '@hcengineering/notification-resources' import { createEventDispatcher } from 'svelte' import NavItem from './NavItem.svelte' @@ -38,9 +43,7 @@ let actions: Action[] = [] notificationClient.inboxNotificationsByContext.subscribe((res) => { - notifications = (res.get(context._id) ?? []).filter( - ({ _class }) => _class === notification.class.ActivityInboxNotification - ) + notifications = (res.get(context._id) ?? []).filter((n) => isMentionNotification(n) || isActivityNotification(n)) }) $: void getNotificationsCount(context, notifications).then((res) => { diff --git a/plugins/chunter-resources/src/utils.ts b/plugins/chunter-resources/src/utils.ts index abb573b698..7837d80d36 100644 --- a/plugins/chunter-resources/src/utils.ts +++ b/plugins/chunter-resources/src/utils.ts @@ -52,7 +52,11 @@ import activity, { type DisplayDocUpdateMessage, type DocUpdateMessage } from '@hcengineering/activity' -import { deleteContextNotifications, InboxNotificationsClientImpl } from '@hcengineering/notification-resources' +import { + deleteContextNotifications, + InboxNotificationsClientImpl, + isMentionNotification +} from '@hcengineering/notification-resources' import notification, { type DocNotifyContext, notificationId } from '@hcengineering/notification' import { get, type Unsubscriber } from 'svelte/store' @@ -479,6 +483,9 @@ export async function readChannelMessages ( return [message._id, ...(combined ?? [])] }) .flat() + const relatedMentions = get(inboxClient.otherInboxNotifications).filter( + (n) => !n.isViewed && isMentionNotification(n) && allIds.includes(n.mentionedIn as Ref) + ) const ops = getClient().apply(generateId()) @@ -486,6 +493,11 @@ export async function readChannelMessages ( void ops.commit() }) + void inboxClient.readNotifications( + client, + relatedMentions.map((n) => n._id) + ) + if (context === undefined) { return } diff --git a/plugins/notification-resources/src/components/inbox/Inbox.svelte b/plugins/notification-resources/src/components/inbox/Inbox.svelte index 33918d26f1..dd33db03d6 100644 --- a/plugins/notification-resources/src/components/inbox/Inbox.svelte +++ b/plugins/notification-resources/src/components/inbox/Inbox.svelte @@ -13,7 +13,11 @@ // limitations under the License. -->