Fix activity for attached documents (#1115)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-03-10 16:05:40 +07:00 committed by GitHub
parent 1647ca4741
commit 178105c657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -53,6 +53,7 @@ export interface DisplayTx {
// A set of collapsed transactions.
txes: DisplayTx[]
txDocIds?: Set<Ref<Doc>>
// type check for createTx
createTx?: TxCreateDoc<Doc>
@ -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<Doc, Doc>).attributes
}
if (result.collectionAttribute !== undefined) {
if (curUpdate === undefined && result.collectionAttribute !== undefined) {
curUpdate = result.collectionAttribute.attributeOf + '.' + result.collectionAttribute.name
}
return curUpdate

View File

@ -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}
<ShowMore ignore={edit}>
<div class="flex-row-center flex-grow flex-wrap">
<TxViewTx {tx} {onCancelEdit} {edit} {viewlet}/>
@ -240,11 +240,11 @@
{#if viewlet && viewlet.component && viewlet.display !== 'inline'}
<div class={viewlet.display}>
<ShowMore ignore={edit}>
{#if tx.collectionAttribute !== undefined && tx.txes.length > 0}
{#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
<div class="flex-row-center flex-grow flex-wrap">
<TxViewTx {tx} {onCancelEdit} {edit} {viewlet}/>
</div>
{:else}
{:else}
{#if typeof viewlet.component === 'string'}
<Component is={viewlet.component} {props} on:close={onCancelEdit} />
{:else}

View File

@ -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) {