mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 11:01:54 +03:00
Remove slow trigger (#6240)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
c675f45491
commit
7bf2a7c8d1
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "desktop",
|
||||
"version": "0.6.266",
|
||||
"version": "0.6.271",
|
||||
"main": "dist/main/electron.js",
|
||||
"author": "Hardcore Engineering <hey@huly.io>",
|
||||
"template": "@hcengineering/default-package",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hcengineering/desktop",
|
||||
"version": "0.6.266",
|
||||
"version": "0.6.271",
|
||||
"main": "dist/main/electron.js",
|
||||
"template": "@hcengineering/webpack-package",
|
||||
"scripts": {
|
||||
|
@ -72,14 +72,6 @@ export function createModel (builder: Builder): void {
|
||||
TNotificationProviderResources
|
||||
)
|
||||
|
||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||
trigger: serverNotification.trigger.OnActivityNotificationViewed,
|
||||
txMatch: {
|
||||
_class: core.class.TxUpdateDoc,
|
||||
objectClass: notification.class.ActivityInboxNotification
|
||||
}
|
||||
})
|
||||
|
||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||
trigger: serverNotification.trigger.OnAttributeCreate,
|
||||
txMatch: {
|
||||
|
@ -579,7 +579,7 @@ export function isActivityMessage (message?: Doc): message is ActivityMessage {
|
||||
return getClient().getHierarchy().isDerived(message._class, activity.class.ActivityMessage)
|
||||
}
|
||||
|
||||
export function isReactionMessage (message?: ActivityMessage): boolean {
|
||||
export function isReactionMessage (message?: ActivityMessage): message is DocUpdateMessage {
|
||||
if (message === undefined) {
|
||||
return false
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import { getClient } from '@hcengineering/presentation'
|
||||
import { type AnySvelteComponent } from '@hcengineering/ui'
|
||||
import { classIcon, getDocLinkTitle, getDocTitle } from '@hcengineering/view-resources'
|
||||
import { get, writable, type Unsubscriber } from 'svelte/store'
|
||||
import { isReactionMessage } from '@hcengineering/activity-resources'
|
||||
|
||||
import ChannelIcon from './components/ChannelIcon.svelte'
|
||||
import DirectIcon from './components/DirectIcon.svelte'
|
||||
@ -439,7 +440,16 @@ export async function readChannelMessages (
|
||||
const allIds = getAllIds(messages).filter((id) => !readMessages.has(id))
|
||||
|
||||
const notifications = get(inboxClient.activityInboxNotifications)
|
||||
.filter(({ _id, attachedTo }) => allIds.includes(attachedTo))
|
||||
.filter(({ attachedTo, $lookup, isViewed }) => {
|
||||
if (isViewed) return false
|
||||
const includes = allIds.includes(attachedTo)
|
||||
if (includes) return true
|
||||
const msg = $lookup?.attachedTo
|
||||
if (isReactionMessage(msg)) {
|
||||
return allIds.includes(msg.attachedTo as Ref<ActivityMessage>)
|
||||
}
|
||||
return false
|
||||
})
|
||||
.map((n) => n._id)
|
||||
|
||||
const relatedMentions = get(inboxClient.otherInboxNotifications)
|
||||
|
@ -1516,58 +1516,6 @@ export async function removeDocInboxNotifications (_id: Ref<ActivityMessage>, co
|
||||
)
|
||||
}
|
||||
|
||||
async function OnActivityNotificationViewed (
|
||||
tx: TxUpdateDoc<InboxNotification>,
|
||||
control: TriggerControl
|
||||
): Promise<Tx[]> {
|
||||
if (tx.objectClass !== notification.class.ActivityInboxNotification || tx.operations.isViewed !== true) {
|
||||
return []
|
||||
}
|
||||
|
||||
const inboxNotification = (
|
||||
await control.findAll(
|
||||
notification.class.ActivityInboxNotification,
|
||||
{
|
||||
_id: tx.objectId as Ref<ActivityInboxNotification>
|
||||
},
|
||||
{ projection: { _id: 1, attachedTo: 1, user: 1 } }
|
||||
)
|
||||
)[0]
|
||||
|
||||
if (inboxNotification === undefined) {
|
||||
return []
|
||||
}
|
||||
|
||||
// Read reactions notifications when message is read
|
||||
const { attachedTo, user } = inboxNotification
|
||||
|
||||
const reactionMessages = await control.findAll(
|
||||
activity.class.DocUpdateMessage,
|
||||
{
|
||||
attachedTo,
|
||||
objectClass: activity.class.Reaction
|
||||
},
|
||||
{ projection: { _id: 1 } }
|
||||
)
|
||||
|
||||
if (reactionMessages.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
const reactionNotifications = await control.findAll(
|
||||
notification.class.ActivityInboxNotification,
|
||||
{
|
||||
attachedTo: { $in: reactionMessages.map(({ _id }) => _id) },
|
||||
user
|
||||
},
|
||||
{ projection: { _id: 1, _class: 1, space: 1 } }
|
||||
)
|
||||
|
||||
return reactionNotifications.map(({ _id, _class, space }) =>
|
||||
control.txFactory.createTxUpdateDoc(_class, space, _id, { isViewed: true })
|
||||
)
|
||||
}
|
||||
|
||||
export async function getCollaborators (
|
||||
doc: Doc,
|
||||
control: TriggerControl,
|
||||
@ -1659,7 +1607,6 @@ export default async () => ({
|
||||
trigger: {
|
||||
OnAttributeCreate,
|
||||
OnAttributeUpdate,
|
||||
OnActivityNotificationViewed,
|
||||
OnDocRemove
|
||||
},
|
||||
function: {
|
||||
|
@ -180,7 +180,6 @@ export default plugin(serverNotificationId, {
|
||||
OnAttributeCreate: '' as Resource<TriggerFunc>,
|
||||
OnAttributeUpdate: '' as Resource<TriggerFunc>,
|
||||
OnReactionChanged: '' as Resource<TriggerFunc>,
|
||||
OnActivityNotificationViewed: '' as Resource<TriggerFunc>,
|
||||
OnDocRemove: '' as Resource<TriggerFunc>
|
||||
},
|
||||
function: {
|
||||
|
Loading…
Reference in New Issue
Block a user