mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 21:35:10 +00:00
UBERF-6509: fix reading mention notifications (#5323)
This commit is contained in:
parent
e6fc2fd12b
commit
6832c9c848
@ -594,3 +594,11 @@ export function isReactionMessage (message?: ActivityMessage): boolean {
|
|||||||
|
|
||||||
return message.objectClass === activity.class.Reaction
|
return message.objectClass === activity.class.Reaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isActivityMessageClass (_class?: Ref<Class<Doc>>): boolean {
|
||||||
|
if (_class === undefined) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return getClient().getHierarchy().isDerived(_class, activity.class.ActivityMessage)
|
||||||
|
}
|
||||||
|
@ -18,7 +18,12 @@
|
|||||||
import { getClient } from '@hcengineering/presentation'
|
import { getClient } from '@hcengineering/presentation'
|
||||||
import { Action, IconEdit } from '@hcengineering/ui'
|
import { Action, IconEdit } from '@hcengineering/ui'
|
||||||
import { getActions } from '@hcengineering/view-resources'
|
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 { createEventDispatcher } from 'svelte'
|
||||||
|
|
||||||
import NavItem from './NavItem.svelte'
|
import NavItem from './NavItem.svelte'
|
||||||
@ -38,9 +43,7 @@
|
|||||||
let actions: Action[] = []
|
let actions: Action[] = []
|
||||||
|
|
||||||
notificationClient.inboxNotificationsByContext.subscribe((res) => {
|
notificationClient.inboxNotificationsByContext.subscribe((res) => {
|
||||||
notifications = (res.get(context._id) ?? []).filter(
|
notifications = (res.get(context._id) ?? []).filter((n) => isMentionNotification(n) || isActivityNotification(n))
|
||||||
({ _class }) => _class === notification.class.ActivityInboxNotification
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
$: void getNotificationsCount(context, notifications).then((res) => {
|
$: void getNotificationsCount(context, notifications).then((res) => {
|
||||||
|
@ -52,7 +52,11 @@ import activity, {
|
|||||||
type DisplayDocUpdateMessage,
|
type DisplayDocUpdateMessage,
|
||||||
type DocUpdateMessage
|
type DocUpdateMessage
|
||||||
} from '@hcengineering/activity'
|
} 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 notification, { type DocNotifyContext, notificationId } from '@hcengineering/notification'
|
||||||
import { get, type Unsubscriber } from 'svelte/store'
|
import { get, type Unsubscriber } from 'svelte/store'
|
||||||
|
|
||||||
@ -479,6 +483,9 @@ export async function readChannelMessages (
|
|||||||
return [message._id, ...(combined ?? [])]
|
return [message._id, ...(combined ?? [])]
|
||||||
})
|
})
|
||||||
.flat()
|
.flat()
|
||||||
|
const relatedMentions = get(inboxClient.otherInboxNotifications).filter(
|
||||||
|
(n) => !n.isViewed && isMentionNotification(n) && allIds.includes(n.mentionedIn as Ref<ActivityMessage>)
|
||||||
|
)
|
||||||
|
|
||||||
const ops = getClient().apply(generateId())
|
const ops = getClient().apply(generateId())
|
||||||
|
|
||||||
@ -486,6 +493,11 @@ export async function readChannelMessages (
|
|||||||
void ops.commit()
|
void ops.commit()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
void inboxClient.readNotifications(
|
||||||
|
client,
|
||||||
|
relatedMentions.map((n) => n._id)
|
||||||
|
)
|
||||||
|
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import notification, { DocNotifyContext, InboxNotification } from '@hcengineering/notification'
|
import notification, {
|
||||||
|
ActivityInboxNotification,
|
||||||
|
DocNotifyContext,
|
||||||
|
InboxNotification
|
||||||
|
} from '@hcengineering/notification'
|
||||||
import { ActionContext, getClient } from '@hcengineering/presentation'
|
import { ActionContext, getClient } from '@hcengineering/presentation'
|
||||||
import view from '@hcengineering/view'
|
import view from '@hcengineering/view'
|
||||||
import {
|
import {
|
||||||
@ -33,13 +37,21 @@
|
|||||||
import chunter, { ThreadMessage } from '@hcengineering/chunter'
|
import chunter, { ThreadMessage } from '@hcengineering/chunter'
|
||||||
import { IdMap, Ref } from '@hcengineering/core'
|
import { IdMap, Ref } from '@hcengineering/core'
|
||||||
import activity, { ActivityMessage } from '@hcengineering/activity'
|
import activity, { ActivityMessage } from '@hcengineering/activity'
|
||||||
import { isReactionMessage } from '@hcengineering/activity-resources'
|
import { isActivityMessageClass, isReactionMessage } from '@hcengineering/activity-resources'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
import { translate } from '@hcengineering/platform'
|
import { translate } from '@hcengineering/platform'
|
||||||
|
|
||||||
import { InboxNotificationsClientImpl } from '../../inboxNotificationsClient'
|
import { InboxNotificationsClientImpl } from '../../inboxNotificationsClient'
|
||||||
import Filter from '../Filter.svelte'
|
import Filter from '../Filter.svelte'
|
||||||
import { archiveAll, getDisplayInboxData, openInboxDoc, readAll, resolveLocation, unreadAll } from '../../utils'
|
import {
|
||||||
|
archiveAll,
|
||||||
|
getDisplayInboxData,
|
||||||
|
isMentionNotification,
|
||||||
|
openInboxDoc,
|
||||||
|
readAll,
|
||||||
|
resolveLocation,
|
||||||
|
unreadAll
|
||||||
|
} from '../../utils'
|
||||||
import { InboxData, InboxNotificationsFilter } from '../../types'
|
import { InboxData, InboxNotificationsFilter } from '../../types'
|
||||||
import InboxGroupedListView from './InboxGroupedListView.svelte'
|
import InboxGroupedListView from './InboxGroupedListView.svelte'
|
||||||
|
|
||||||
@ -161,7 +173,19 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hierarchy.isDerived(selectedContext.attachedToClass, activity.class.ActivityMessage)) {
|
const selectedNotification: InboxNotification | undefined = event?.detail?.notification
|
||||||
|
|
||||||
|
if (isMentionNotification(selectedNotification) && isActivityMessageClass(selectedNotification.mentionedInClass)) {
|
||||||
|
const selectedMsg = selectedNotification.mentionedIn as Ref<ActivityMessage>
|
||||||
|
|
||||||
|
openInboxDoc(
|
||||||
|
selectedContext._id,
|
||||||
|
isActivityMessageClass(selectedContext.attachedToClass)
|
||||||
|
? (selectedContext.attachedTo as Ref<ActivityMessage>)
|
||||||
|
: undefined,
|
||||||
|
selectedMsg
|
||||||
|
)
|
||||||
|
} else if (hierarchy.isDerived(selectedContext.attachedToClass, activity.class.ActivityMessage)) {
|
||||||
const message = event?.detail?.notification?.$lookup?.attachedTo
|
const message = event?.detail?.notification?.$lookup?.attachedTo
|
||||||
|
|
||||||
if (selectedContext.attachedToClass === chunter.class.ThreadMessage) {
|
if (selectedContext.attachedToClass === chunter.class.ThreadMessage) {
|
||||||
@ -172,7 +196,7 @@
|
|||||||
} else if (isReactionMessage(message)) {
|
} else if (isReactionMessage(message)) {
|
||||||
openInboxDoc(selectedContext._id, undefined, selectedContext.attachedTo as Ref<ActivityMessage>)
|
openInboxDoc(selectedContext._id, undefined, selectedContext.attachedTo as Ref<ActivityMessage>)
|
||||||
} else {
|
} else {
|
||||||
const selectedMsg = event?.detail?.notification?.attachedTo
|
const selectedMsg = (selectedNotification as ActivityInboxNotification)?.attachedTo
|
||||||
|
|
||||||
openInboxDoc(
|
openInboxDoc(
|
||||||
selectedContext._id,
|
selectedContext._id,
|
||||||
@ -181,7 +205,7 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
openInboxDoc(selectedContext._id, undefined, event?.detail?.notification?.attachedTo)
|
openInboxDoc(selectedContext._id, undefined, (selectedNotification as ActivityInboxNotification)?.attachedTo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,8 @@ import notification, {
|
|||||||
type Collaborators,
|
type Collaborators,
|
||||||
type DisplayInboxNotification,
|
type DisplayInboxNotification,
|
||||||
type DocNotifyContext,
|
type DocNotifyContext,
|
||||||
type InboxNotification
|
type InboxNotification,
|
||||||
|
type MentionInboxNotification
|
||||||
} from '@hcengineering/notification'
|
} from '@hcengineering/notification'
|
||||||
import { MessageBox, getClient } from '@hcengineering/presentation'
|
import { MessageBox, getClient } from '@hcengineering/presentation'
|
||||||
import { getLocation, navigate, showPopup, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
import { getLocation, navigate, showPopup, type Location, type ResolvedLocation } from '@hcengineering/ui'
|
||||||
@ -274,10 +275,16 @@ export async function unreadAll (): Promise<void> {
|
|||||||
await client.unreadAllNotifications()
|
await client.unreadAllNotifications()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isActivityNotification (doc: InboxNotification): doc is ActivityInboxNotification {
|
export function isActivityNotification (doc?: InboxNotification): doc is ActivityInboxNotification {
|
||||||
|
if (doc === undefined) return false
|
||||||
return doc._class === notification.class.ActivityInboxNotification
|
return doc._class === notification.class.ActivityInboxNotification
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isMentionNotification (doc?: InboxNotification): doc is MentionInboxNotification {
|
||||||
|
if (doc === undefined) return false
|
||||||
|
return doc._class === notification.class.MentionInboxNotification
|
||||||
|
}
|
||||||
|
|
||||||
export async function getDisplayInboxNotifications (
|
export async function getDisplayInboxNotifications (
|
||||||
notifications: Array<WithLookup<InboxNotification>>,
|
notifications: Array<WithLookup<InboxNotification>>,
|
||||||
filter: InboxNotificationsFilter = 'all',
|
filter: InboxNotificationsFilter = 'all',
|
||||||
|
Loading…
Reference in New Issue
Block a user