From 556cfb31d076f1d1ab2e923ffa2a7b0035fa1ff0 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 7 Apr 2023 23:13:56 +0600 Subject: [PATCH] Fix activity is new (#2923) Signed-off-by: Denis Bykhov --- .../src/components/Activity.svelte | 4 ++-- .../src/components/ActivityFilter.svelte | 8 ++------ .../activity-resources/src/components/TxView.svelte | 8 ++++---- .../activity/ActivityChannelMessage.svelte | 13 ++++++++++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index 59d2d68ce0..88df25bac3 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -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} {#each filtered as tx, i} - = i && newTxPos !== -1} isNextNew={newTxPos > i && newTxPos !== -1} /> + {/each} {/if} diff --git a/plugins/activity-resources/src/components/ActivityFilter.svelte b/plugins/activity-resources/src/components/ActivityFilter.svelte index 6041e166ae..3d09a4eb74 100644 --- a/plugins/activity-resources/src/components/ActivityFilter.svelte +++ b/plugins/activity-resources/src/components/ActivityFilter.svelte @@ -83,9 +83,7 @@ ): Promise { 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) => 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) } } diff --git a/plugins/activity-resources/src/components/TxView.svelte b/plugins/activity-resources/src/components/TxView.svelte index 2ae4ed0ef0..ecb20265db 100644 --- a/plugins/activity-resources/src/components/TxView.svelte +++ b/plugins/activity-resources/src/components/TxView.svelte @@ -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 { diff --git a/plugins/contact-resources/src/components/activity/ActivityChannelMessage.svelte b/plugins/contact-resources/src/components/activity/ActivityChannelMessage.svelte index e6e3ced93d..707dfd2393 100644 --- a/plugins/contact-resources/src/components/activity/ActivityChannelMessage.svelte +++ b/plugins/contact-resources/src/components/activity/ActivityChannelMessage.svelte @@ -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[]): DisplayTx[] { return txes.map((p) => newDisplayTx(TxProcessor.extractTx(p) as TxCUD, hierarchy)) }