diff --git a/plugins/activity-resources/src/activity.ts b/plugins/activity-resources/src/activity.ts index 082dadb62d..ff54688b7c 100644 --- a/plugins/activity-resources/src/activity.ts +++ b/plugins/activity-resources/src/activity.ts @@ -53,6 +53,7 @@ export interface DisplayTx { // A set of collapsed transactions. txes: DisplayTx[] + txDocIds?: Set> // type check for createTx createTx?: TxCreateDoc @@ -314,6 +315,15 @@ class ActivityImpl implements Activity { if (result.tx.modifiedOn - prevTx.tx.modifiedOn < combineThreshold && isEqualOps(prevUpdate, curUpdate)) { // we have same keys, // Remember previous transactions + if (result.txDocIds === undefined) { + result.txDocIds = new Set() + } + if (prevTx.doc?._id !== undefined) { + result.txDocIds?.add(prevTx.doc._id) + } + if (result.doc?._id !== undefined) { + result.txDocIds?.add(result.doc._id) + } result.txes.push(...prevTx.txes, prevTx) return false } @@ -343,7 +353,7 @@ function getCombineOpFromTx (result: DisplayTx): any { if (result.tx._class === core.class.TxMixin) { curUpdate = (result.tx as unknown as TxMixin).attributes } - if (result.collectionAttribute !== undefined) { + if (curUpdate === undefined && result.collectionAttribute !== undefined) { curUpdate = result.collectionAttribute.attributeOf + '.' + result.collectionAttribute.name } return curUpdate diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index c634a30751..8c0989b916 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -217,7 +217,7 @@ {/await} {/each} {:else if viewlet && viewlet.display === 'inline' && viewlet.component} - {#if tx.collectionAttribute !== undefined && tx.txes.length > 0} + {#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
@@ -240,11 +240,11 @@ {#if viewlet && viewlet.component && viewlet.display !== 'inline'}
- {#if tx.collectionAttribute !== undefined && tx.txes.length > 0} + {#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
- {:else} + {:else} {#if typeof viewlet.component === 'string'} {:else} diff --git a/plugins/activity-resources/src/components/utils.ts b/plugins/activity-resources/src/components/utils.ts index d7ac4c516d..989f1f74d4 100644 --- a/plugins/activity-resources/src/components/utils.ts +++ b/plugins/activity-resources/src/components/utils.ts @@ -89,7 +89,7 @@ async function checkInlineViewlets ( client: TxOperations, model: AttributeModel[] ): Promise<{ viewlet: TxDisplayViewlet, model: AttributeModel[] }> { - if (dtx.collectionAttribute !== undefined && dtx.txes.length > 0) { + if (dtx.collectionAttribute !== undefined && (dtx.txDocIds?.size ?? 0) > 1) { // Check if we have a class presenter we could have a pseudo viewlet based on class presenter. viewlet = await createPseudoViewlet(client, dtx, activity.string.CollectionUpdated, 'content') } else if (dtx.tx._class === core.class.TxCreateDoc) {