diff --git a/models/activity/package.json b/models/activity/package.json index 00d35887ac..71570dd350 100644 --- a/models/activity/package.json +++ b/models/activity/package.json @@ -35,6 +35,7 @@ "@hcengineering/model": "^0.6.11", "@hcengineering/model-core": "^0.6.0", "@hcengineering/model-preference": "^0.6.0", + "@hcengineering/model-presentation": "^0.6.0", "@hcengineering/model-view": "^0.6.0", "@hcengineering/notification": "^0.6.23", "@hcengineering/platform": "^0.6.11", diff --git a/models/activity/src/index.ts b/models/activity/src/index.ts index c14f33b646..6d63a993c0 100644 --- a/models/activity/src/index.ts +++ b/models/activity/src/index.ts @@ -70,6 +70,7 @@ import preference, { TPreference } from '@hcengineering/model-preference' import view from '@hcengineering/model-view' import type { Asset, IntlString, Resource } from '@hcengineering/platform' import { type AnyComponent } from '@hcengineering/ui/src/types' +import presentation from '@hcengineering/model-presentation' import activity from './plugin' import { buildActions } from './actions' @@ -375,6 +376,10 @@ export function createModel (builder: Builder): void { ] }) + builder.mixin(activity.class.Reaction, core.class.Class, presentation.mixin.InstantTransactions, { + txClasses: [core.class.TxCreateDoc] + }) + buildActions(builder) buildNotifications(builder) } diff --git a/packages/core/src/operations.ts b/packages/core/src/operations.ts index 5dd2c35e4c..9db10bdae0 100644 --- a/packages/core/src/operations.ts +++ b/packages/core/src/operations.ts @@ -98,7 +98,7 @@ export class TxOperations implements Omit { throw new Error('createDoc cannot be called for DOMAIN_MODEL classes with non-model space') } const tx = this.txFactory.createTxCreateDoc(_class, space, attributes, id, modifiedOn, modifiedBy) - await this.client.tx(tx) + await this.tx(tx) return tx.objectId } @@ -122,7 +122,7 @@ export class TxOperations implements Omit { modifiedOn, modifiedBy ) - await this.client.tx(tx) + await this.tx(tx) return tx.tx.objectId as unknown as Ref

} @@ -147,7 +147,7 @@ export class TxOperations implements Omit { modifiedOn, modifiedBy ) - await this.client.tx(tx) + await this.tx(tx) return tx.objectId } @@ -170,7 +170,7 @@ export class TxOperations implements Omit { modifiedOn, modifiedBy ) - await this.client.tx(tx) + await this.tx(tx) return tx.objectId } @@ -184,7 +184,7 @@ export class TxOperations implements Omit { modifiedBy?: Ref ): Promise { const tx = this.txFactory.createTxUpdateDoc(_class, space, objectId, operations, retrieve, modifiedOn, modifiedBy) - return this.client.tx(tx) + return this.tx(tx) } removeDoc( @@ -195,7 +195,7 @@ export class TxOperations implements Omit { modifiedBy?: Ref ): Promise { const tx = this.txFactory.createTxRemoveDoc(_class, space, objectId, modifiedOn, modifiedBy) - return this.client.tx(tx) + return this.tx(tx) } createMixin( @@ -216,7 +216,7 @@ export class TxOperations implements Omit { modifiedOn, modifiedBy ) - return this.client.tx(tx) + return this.tx(tx) } updateMixin( @@ -237,7 +237,7 @@ export class TxOperations implements Omit { modifiedOn, modifiedBy ) - return this.client.tx(tx) + return this.tx(tx) } async update( diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index 9fea4555e9..5a2cc7db4f 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -211,6 +211,11 @@ { sort: { createdOn: SortingOrder.Ascending + }, + lookup: { + _id: { + reactions: activity.class.Reaction + } } } ) diff --git a/plugins/activity-resources/src/components/reactions/Reactions.svelte b/plugins/activity-resources/src/components/reactions/Reactions.svelte index 7df064d594..440cb291ba 100644 --- a/plugins/activity-resources/src/components/reactions/Reactions.svelte +++ b/plugins/activity-resources/src/components/reactions/Reactions.svelte @@ -55,7 +55,7 @@ ev.preventDefault() ev.stopPropagation() showPopup(EmojiPopup, {}, ev.target as HTMLElement, async (emoji: string) => { - await updateDocReactions(client, reactions, object, emoji) + await updateDocReactions(reactions, object, emoji) }) } diff --git a/plugins/activity-resources/src/components/reactions/ReactionsPresenter.svelte b/plugins/activity-resources/src/components/reactions/ReactionsPresenter.svelte index a495545053..86eb49e3a1 100644 --- a/plugins/activity-resources/src/components/reactions/ReactionsPresenter.svelte +++ b/plugins/activity-resources/src/components/reactions/ReactionsPresenter.svelte @@ -14,40 +14,48 @@ --> -{#if object && hasReactions} +{#if object && reactions.length > 0}

diff --git a/plugins/activity-resources/src/components/reactions/ReactionsPreview.svelte b/plugins/activity-resources/src/components/reactions/ReactionsPreview.svelte index 9e5f5374c0..917e11a97a 100644 --- a/plugins/activity-resources/src/components/reactions/ReactionsPreview.svelte +++ b/plugins/activity-resources/src/components/reactions/ReactionsPreview.svelte @@ -66,7 +66,7 @@ e.stopPropagation() e.preventDefault() showPopup(EmojiPopup, {}, e.target as HTMLElement, (emoji: string) => { - void updateDocReactions(client, reactions, message, emoji) + void updateDocReactions(reactions, message, emoji) }) } diff --git a/plugins/activity-resources/src/utils.ts b/plugins/activity-resources/src/utils.ts index 7a91bb20bb..06df26ee33 100644 --- a/plugins/activity-resources/src/utils.ts +++ b/plugins/activity-resources/src/utils.ts @@ -1,12 +1,5 @@ import type { ActivityMessage, Reaction } from '@hcengineering/activity' -import core, { - getCurrentAccount, - isOtherHour, - type Doc, - type Ref, - type TxOperations, - type Space -} from '@hcengineering/core' +import core, { getCurrentAccount, isOtherHour, type Doc, type Ref, type Space } from '@hcengineering/core' import { getClient, isSpace } from '@hcengineering/presentation' import { EmojiPopup, @@ -22,18 +15,13 @@ import { get } from 'svelte/store' import { savedMessagesStore } from './activity' import activity from './plugin' -export async function updateDocReactions ( - client: TxOperations, - reactions: Reaction[], - object?: Doc, - emoji?: string -): Promise { +export async function updateDocReactions (reactions: Reaction[], object?: Doc, emoji?: string): Promise { if (emoji === undefined || object === undefined) { return } + const client = getClient() const currentAccount = getCurrentAccount() - const reaction = reactions.find((r) => r.emoji === emoji && r.createBy === currentAccount._id) if (reaction == null) { @@ -72,7 +60,7 @@ export async function addReactionAction ( closePopup() showPopup(EmojiPopup, {}, element, (emoji: string) => { - void updateDocReactions(client, reactions, message, emoji) + void updateDocReactions(reactions, message, emoji) params?.onClose?.() }) params?.onOpen?.() diff --git a/plugins/chunter-resources/src/channelDataProvider.ts b/plugins/chunter-resources/src/channelDataProvider.ts index 66244cb07d..9de379d93c 100644 --- a/plugins/chunter-resources/src/channelDataProvider.ts +++ b/plugins/chunter-resources/src/channelDataProvider.ts @@ -20,6 +20,7 @@ import { type DocumentQuery, getCurrentAccount, isOtherDay, + type Lookup, type Ref, SortingOrder, type Space, @@ -285,13 +286,21 @@ export class ChannelDataProvider implements IChannelDataProvider { }, { sort: { createdOn: SortingOrder.Descending }, - lookup: { - _id: { attachments: attachment.class.Attachment, inlineButtons: chunter.class.InlineButton } - } + lookup: this.getLookup() } ) } + getLookup (): Lookup { + return { + _id: { + attachments: attachment.class.Attachment, + inlineButtons: chunter.class.InlineButton, + reactions: activity.class.Reaction + } + } + } + isNextLoading (mode: LoadMode): boolean { return mode === 'forward' ? get(this.isForwardLoading) : get(this.isBackwardLoading) } @@ -331,9 +340,7 @@ export class ChannelDataProvider implements IChannelDataProvider { { limit: limit ?? this.limit, sort: { createdOn: isBackward ? SortingOrder.Descending : SortingOrder.Ascending }, - lookup: { - _id: { attachments: attachment.class.Attachment, inlineButtons: chunter.class.InlineButton } - } + lookup: this.getLookup() } )