Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-06-03 00:42:44 +07:00 committed by GitHub
parent 268f14b061
commit 57ff7642dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 34 deletions

View File

@ -337,7 +337,7 @@ class ActivityImpl implements Activity {
// we have same keys,
// Remember previous transactions
if (result.txDocIds === undefined) {
result.txDocIds = new Set(prevTx.txDocIds)
result.txDocIds = new Set()
}
if (prevTx.doc?._id !== undefined) {
result.txDocIds?.add(prevTx.doc._id)

View File

@ -21,7 +21,6 @@
import { Component, Grid, IconActivity, Label, Scroller } from '@anticrm/ui'
import { ActivityKey, activityKey, DisplayTx, newActivity } from '../activity'
import TxView from './TxView.svelte'
import { filterCollectionTxes } from './utils'
export let object: Doc
export let integrate: boolean = false
@ -49,7 +48,7 @@
$: activityQuery.update(
object,
(result) => {
txes = filterCollectionTxes(result)
txes = result
},
SortingOrder.Descending,
new Map(

View File

@ -249,7 +249,7 @@
{/await}
{/each}
{:else if viewlet && viewlet.display === 'inline' && viewlet.component}
{#if tx.collectionAttribute !== undefined}
{#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
<ShowMore ignore={edit}>
<div class="flex-row-center flex-grow flex-wrap clear-mins">
<TxViewTx {tx} {onCancelEdit} {edit} {viewlet} />
@ -270,7 +270,7 @@
{#if viewlet && viewlet.component && viewlet.display !== 'inline'}
<div class={viewlet.display}>
<ShowMore ignore={edit}>
{#if tx.collectionAttribute !== undefined}
{#if tx.collectionAttribute !== undefined && (tx.txDocIds?.size ?? 0) > 1}
<div class="flex-row-center flex-grow flex-wrap clear-mins">
<TxViewTx {tx} {onCancelEdit} {edit} {viewlet} />
</div>

View File

@ -22,7 +22,7 @@
</script>
<div class="flex-row-center flex-grow flex-wrap content">
{#each filterTx([...tx.txes, tx], core.class.TxCreateDoc) as ctx, i}
{#each filterTx([tx, ...tx.txes], core.class.TxCreateDoc) as ctx, i}
{#if i === 0}
<div class="mr-2"><IconAdd size={'small'} /></div>
{/if}
@ -34,7 +34,7 @@
{/if}
</div>
{/each}
{#each filterTx([...tx.txes, tx], core.class.TxRemoveDoc) as ctx, i}
{#each filterTx([tx, ...tx.txes], core.class.TxRemoveDoc) as ctx, i}
{#if i === 0}
<div class="mr-2"><IconDelete size={'small'} /></div>
{/if}

View File

@ -125,7 +125,7 @@ async function checkInlineViewlets (
client: TxOperations,
model: AttributeModel[]
): Promise<{ viewlet: TxDisplayViewlet, model: AttributeModel[] }> {
if (dtx.collectionAttribute !== undefined) {
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) {
@ -252,29 +252,3 @@ export async function getValue (client: TxOperations, m: AttributeModel, tx: Dis
}
return value
}
export function filterCollectionTxes (txes: DisplayTx[]): DisplayTx[] {
return txes.map(filterCollectionTx).filter(Boolean) as DisplayTx[]
}
function filterCollectionTx (tx: DisplayTx): DisplayTx | undefined {
if (tx.collectionAttribute === undefined) return tx
const txes = tx.txes.reduceRight(
(txes, ctx) => {
const filtredTxes = txes.filter(
({ tx: { _class }, doc }) => doc?._id !== ctx.doc?._id || _class === core.class.TxUpdateDoc
)
return ctx.tx._class === core.class.TxUpdateDoc || filtredTxes.length === txes.length
? [ctx, ...txes]
: filtredTxes
},
[tx]
)
const txDocIds = txes.map(({ doc }) => doc?._id).filter(Boolean) as Array<Ref<Doc>>
const ctx = txes.pop()
if (ctx !== undefined) {
ctx.txes = txes
ctx.txDocIds = new Set(txDocIds)
}
return ctx
}