Fix activity is new ()

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-07 23:13:56 +06:00 committed by GitHub
parent 650e65a7f9
commit 556cfb31d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 15 deletions
plugins
activity-resources/src/components
contact-resources/src/components/activity

View File

@ -88,7 +88,7 @@
if (lastView === undefined || lastView === -1) return -1
for (let index = 0; index < txes.length; index++) {
const tx = txes[index]
if (tx.tx.modifiedOn <= lastView) return index - 1
if (tx.tx.modifiedOn > lastView) return index - 1
}
return -1
}
@ -109,7 +109,7 @@
{#if filtered}
<Grid column={1} rowGap={0.75}>
{#each filtered as tx, i}
<TxView {tx} {viewlets} isNew={newTxPos >= i && newTxPos !== -1} isNextNew={newTxPos > i && newTxPos !== -1} />
<TxView {tx} {viewlets} isNew={newTxPos < i && newTxPos !== -1} isNextNew={newTxPos <= i && newTxPos !== -1} />
{/each}
</Grid>
{/if}

View File

@ -83,9 +83,7 @@
): Promise<void> {
if (selected === 'All') {
filtered = txes
if (extraComponent === undefined) {
dispatch('update', filtered)
}
dispatch('update', filtered)
} else {
const selectedFilters = filters.filter((filter) => selected.includes(filter._id))
const filterActions: ((tx: DisplayTx, _class?: Ref<Doc>) => boolean)[] = []
@ -96,9 +94,7 @@
filterActions.push(fltr)
}
filtered = txes.filter((it) => filterActions.some((f) => f(it, object._class)))
if (extraComponent === undefined) {
dispatch('update', filtered)
}
dispatch('update', filtered)
}
}

View File

@ -419,10 +419,10 @@
.icon {
border: 1px solid var(--highlight-red);
}
&.isNextNew {
&:after {
background-color: var(--highlight-red);
}
}
&.isNextNew {
&::after {
background-color: var(--highlight-red);
}
}
&::before {

View File

@ -43,6 +43,8 @@
}
)
let newTxes: DisplayTx[] = []
const txQuery = createQuery()
$: txQuery.query(
core.class.TxCollectionCUD,
@ -52,12 +54,17 @@
'tx.attributes.incoming': false
},
(res) => {
const newTxes = createDisplayTxes(res)
const result = filtered.concat(newTxes).sort((a, b) => a.tx.modifiedOn - b.tx.modifiedOn)
dispatch('update', result)
newTxes = createDisplayTxes(res)
}
)
function update (filtered: DisplayTx[], newTxes: DisplayTx[]) {
const result = filtered.concat(newTxes).sort((a, b) => a.tx.modifiedOn - b.tx.modifiedOn)
dispatch('update', result)
}
$: update(filtered, newTxes)
function createDisplayTxes (txes: TxCollectionCUD<Doc, AttachedDoc>[]): DisplayTx[] {
return txes.map((p) => newDisplayTx(TxProcessor.extractTx(p) as TxCUD<Doc>, hierarchy))
}