From f1da8ff9b1bcd68508589b4c08cf8f69860ee590 Mon Sep 17 00:00:00 2001 From: Kristina Date: Tue, 24 Sep 2024 21:24:17 +0400 Subject: [PATCH] Fix inbox rerender on delete (#6709) Signed-off-by: Kristina Fefelova --- packages/ui/src/components/ListView.svelte | 2 +- .../src/components/inbox/Inbox.svelte | 4 ++-- .../src/components/inbox/InboxGroupedListView.svelte | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/ListView.svelte b/packages/ui/src/components/ListView.svelte index 0cd7be0cc2..9eb38abfd2 100644 --- a/packages/ui/src/components/ListView.svelte +++ b/packages/ui/src/components/ListView.svelte @@ -28,7 +28,7 @@ export let lazy = false export let minHeight: string | null = null export let highlightIndex: number | undefined = undefined - const getKey: (index: number) => string = (index) => index.toString() + export let getKey: (index: number) => string = (index) => index.toString() const refs: HTMLElement[] = [] diff --git a/plugins/notification-resources/src/components/inbox/Inbox.svelte b/plugins/notification-resources/src/components/inbox/Inbox.svelte index 5365b49ea1..f66650eb87 100644 --- a/plugins/notification-resources/src/components/inbox/Inbox.svelte +++ b/plugins/notification-resources/src/components/inbox/Inbox.svelte @@ -171,7 +171,8 @@ const [id, _class] = decodeObjectURI(loc?.loc.path[3] ?? '') const _id = await parseLinkId(linkProviders, id, _class) - const context = _id ? $contextByDocStore.get(_id) : undefined + const thread = loc?.loc.path[4] as Ref + const context = $contextByDocStore.get(thread) ?? $contextByDocStore.get(_id) selectedContextId = context?._id @@ -180,7 +181,6 @@ } const selectedMessageId = loc?.loc.query?.message as Ref | undefined - const thread = loc?.loc.path[4] as Ref | undefined if (thread !== undefined) { const fn = await getResource(chunter.function.OpenThreadInSidebar) diff --git a/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte b/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte index cf624494e0..12a73cb798 100644 --- a/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte +++ b/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte @@ -93,6 +93,11 @@ $: if (element != null) { element.focus() } + + function getContextKey (index: number): string { + const contextId = displayData[index][0] + return contextId ?? index.toString() + } @@ -108,6 +113,7 @@ kind="full-size" colorsSchema="lumia" lazy={true} + getKey={getContextKey} > {@const contextId = displayData[itemIndex][0]}