mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 11:01:54 +03:00
Fix duplicates of inbox notifications and notify contexts (#4383)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
96bd320f59
commit
c6d6b48318
@ -209,8 +209,9 @@ export function sortActivityMessages<T extends ActivityMessage> (messages: T[],
|
||||
function canCombineMessage (message: ActivityMessage): boolean {
|
||||
const hasReactions = message.reactions !== undefined && message.reactions > 0
|
||||
const isPinned = message.isPinned === true
|
||||
const hasReplies = message.replies !== undefined && message.replies > 0
|
||||
|
||||
return !hasReactions && !isPinned
|
||||
return !hasReactions && !isPinned && !hasReplies
|
||||
}
|
||||
|
||||
function groupByTime<T extends ActivityMessage> (messages: T[]): T[][] {
|
||||
|
@ -31,6 +31,7 @@ import core, {
|
||||
MixinUpdate,
|
||||
Ref,
|
||||
RefTo,
|
||||
Space,
|
||||
Timestamp,
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
@ -389,7 +390,9 @@ export async function pushInboxNotifications (
|
||||
control: TriggerControl,
|
||||
res: Tx[],
|
||||
targetUser: Ref<Account>,
|
||||
object: Doc,
|
||||
attachedTo: Ref<Doc>,
|
||||
attachedToClass: Ref<Class<Doc>>,
|
||||
space: Ref<Space>,
|
||||
docNotifyContexts: DocNotifyContext[],
|
||||
data: Partial<Data<InboxNotification>>,
|
||||
_class: Ref<Class<InboxNotification>>,
|
||||
@ -404,10 +407,10 @@ export async function pushInboxNotifications (
|
||||
let docNotifyContextId: Ref<DocNotifyContext>
|
||||
|
||||
if (docNotifyContext === undefined) {
|
||||
const createContextTx = control.txFactory.createTxCreateDoc(notification.class.DocNotifyContext, object.space, {
|
||||
const createContextTx = control.txFactory.createTxCreateDoc(notification.class.DocNotifyContext, space, {
|
||||
user: targetUser,
|
||||
attachedTo: object._id,
|
||||
attachedToClass: object._class,
|
||||
attachedTo,
|
||||
attachedToClass,
|
||||
hidden: false,
|
||||
lastUpdateTimestamp: shouldUpdateTimestamp ? modifiedOn : undefined
|
||||
})
|
||||
@ -426,7 +429,7 @@ export async function pushInboxNotifications (
|
||||
|
||||
if (!isHidden) {
|
||||
res.push(
|
||||
control.txFactory.createTxCreateDoc(_class, object.space, {
|
||||
control.txFactory.createTxCreateDoc(_class, space, {
|
||||
user: targetUser,
|
||||
isViewed: false,
|
||||
docNotifyContext: docNotifyContextId,
|
||||
@ -469,7 +472,9 @@ export async function pushActivityInboxNotifications (
|
||||
control,
|
||||
res,
|
||||
targetUser,
|
||||
object,
|
||||
activityMessage.attachedTo,
|
||||
activityMessage.attachedToClass,
|
||||
activityMessage.space,
|
||||
docNotifyContexts,
|
||||
data,
|
||||
notification.class.ActivityInboxNotification,
|
||||
@ -547,7 +552,9 @@ export async function createCollabDocInfo (
|
||||
}
|
||||
|
||||
const targets = new Set(collaborators)
|
||||
const notifyContexts = await control.findAll(notification.class.DocNotifyContext, { attachedTo: object._id })
|
||||
const notifyContexts = await control.findAll(notification.class.DocNotifyContext, {
|
||||
attachedTo: activityMessage.attachedTo
|
||||
})
|
||||
|
||||
for (const target of targets) {
|
||||
res = res.concat(
|
||||
@ -714,6 +721,17 @@ async function collectionCollabDoc (
|
||||
return res
|
||||
}
|
||||
|
||||
const isNotificationPushed = (res as TxCUD<Doc>[])
|
||||
.filter(
|
||||
(ctx: TxCUD<Doc>): ctx is TxCreateDoc<ActivityInboxNotification> =>
|
||||
ctx._class === core.class.TxCreateDoc && ctx.objectClass === notification.class.ActivityInboxNotification
|
||||
)
|
||||
.some(({ attributes }) => attributes.attachedTo === activityMessage._id)
|
||||
|
||||
if (isNotificationPushed) {
|
||||
return res
|
||||
}
|
||||
|
||||
const mixin = control.hierarchy.classHierarchyMixin(tx.objectClass, notification.mixin.ClassCollaborators)
|
||||
|
||||
if (mixin === undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user