From 43713dd5089fea1a28905dc551625b9b8017aa5b Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 21 Apr 2023 12:43:27 +0600 Subject: [PATCH] Inbox scroll to new (#3036) Signed-off-by: Denis Bykhov --- packages/panel/src/components/Panel.svelte | 10 ++++++-- .../src/components/Activity.svelte | 25 ++++++++++++++++++- .../src/components/TxView.svelte | 21 +++++++++++++++- .../src/components/NotificationView.svelte | 2 +- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/packages/panel/src/components/Panel.svelte b/packages/panel/src/components/Panel.svelte index 69993bae6a..16fb676b66 100644 --- a/packages/panel/src/components/Panel.svelte +++ b/packages/panel/src/components/Panel.svelte @@ -143,7 +143,10 @@
{#if !withoutActivity} - + {/if}
{:else} @@ -151,7 +154,10 @@
{#if !withoutActivity} - + {/if}
diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index bccf8a4fdf..d2dcb42909 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -28,6 +28,7 @@ export let object: Doc export let showCommenInput: boolean = true export let transparent: boolean = false + export let shouldScroll: boolean = false getResource(notification.function.GetNotificationClient).then((res) => { updatesStore = res().docUpdatesStore @@ -83,13 +84,29 @@ let filtered: DisplayTx[] = [] + let newTxIndexes: number[] = [] + $: newTxIndexes = getNewTxes(filtered, newTxes) + + function getNewTxes (filtered: DisplayTx[], newTxes: [Ref>, number][]): number[] { + const res: number[] = [] + for (let i = 0; i < filtered.length; i++) { + if (isNew(filtered[i], newTxes)) { + res.push(i) + } + } + return res + } + function isNew (tx: DisplayTx | undefined, newTxes: [Ref>, number][]): boolean { if (tx === undefined) return false const index = newTxes.findIndex((p) => p[0] === tx.originTx._id) return index !== -1 } + + $: scrollIndex = shouldScroll ? newTxIndexes[0] ?? -1 : -1 +{shouldScroll}