From 581cb3505a042c1d53c4e0277ad8031cfd17cb45 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 22 Jan 2024 18:34:39 +0400 Subject: [PATCH] UBERF-5012: remove extra key (avoid reloading after notifications deleting) (#4399) Signed-off-by: Kristina Fefelova --- .../src/components/inbox/Inbox.svelte | 17 +++---- .../components/inbox/InboxFlatListView.svelte | 44 +++++++++---------- .../inbox/InboxGroupedListView.svelte | 28 ++++++------ 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/plugins/notification-resources/src/components/inbox/Inbox.svelte b/plugins/notification-resources/src/components/inbox/Inbox.svelte index ee238e7a41..1511b67e01 100644 --- a/plugins/notification-resources/src/components/inbox/Inbox.svelte +++ b/plugins/notification-resources/src/components/inbox/Inbox.svelte @@ -44,6 +44,7 @@ import Filter from '../Filter.svelte' import { getDisplayInboxNotifications, resolveLocation } from '../../utils' import { InboxNotificationsFilter } from '../../types' + import { onDestroy } from 'svelte' export let visibleNav: boolean = true export let navFloat: boolean = false @@ -55,8 +56,6 @@ const notificationsByContextStore = inboxClient.inboxNotificationsByContext const notifyContextsStore = inboxClient.docNotifyContexts - const checkedContexts = new Set>() - const allTab: TabItem = { id: 'all', labelIntl: notification.string.All @@ -71,11 +70,12 @@ } let displayNotifications: DisplayInboxNotification[] = [] + let displayContextsIds = new Set>() + let filteredNotifications: DisplayInboxNotification[] = [] let filter: InboxNotificationsFilter = 'all' let tabItems: TabItem[] = [] - let displayContextsIds = new Set>() let selectedTabId: string = allTab.id let selectedContextId: Ref | undefined = undefined @@ -83,6 +83,7 @@ let selectedComponent: AnyComponent | undefined = undefined let viewlets: ActivityNotificationViewlet[] = [] + let viewlet: WithLookup | undefined let loading = true @@ -91,10 +92,9 @@ }) $: displayNotifications = getDisplayInboxNotifications($notificationsByContextStore, filter) + $: displayContextsIds = new Set(displayNotifications.map(({ docNotifyContext }) => docNotifyContext)) - locationStore.subscribe((newLocation) => { - syncLocation(newLocation) - }) + $: filteredNotifications = filterNotifications(selectedTabId, displayNotifications, $notifyContextsStore) async function syncLocation (newLocation: Location) { const loc = await resolveLocation(newLocation) @@ -110,11 +110,8 @@ ? selectedContext ?? $notifyContextsStore.find(({ _id }) => _id === selectedContextId) : undefined - $: displayContextsIds = new Set(displayNotifications.map(({ docNotifyContext }) => docNotifyContext)) $: updateSelectedPanel(selectedContext) - $: updateTabItems(displayContextsIds, $notifyContextsStore) - $: filteredNotifications = filterNotifications(selectedTabId, displayNotifications, $notifyContextsStore) function updateTabItems (displayContextsIds: Set>, notifyContexts: DocNotifyContext[]): void { const displayClasses = new Set( @@ -174,6 +171,7 @@ const isChunterChannel = hierarchy.isDerived(selectedContext.attachedToClass, chunter.class.ChunterSpace) const panelComponent = hierarchy.classHierarchyMixin(selectedContext.attachedToClass, view.mixin.ObjectPanel) + selectedComponent = panelComponent?.component ?? view.component.EditDoc const contextNotifications = $notificationsByContextStore.get(selectedContext._id) ?? [] @@ -246,7 +244,6 @@ is={viewlet.$lookup.descriptor.component} props={{ notifications: filteredNotifications, - checkedContexts, viewlets, selectedContext }} diff --git a/plugins/notification-resources/src/components/inbox/InboxFlatListView.svelte b/plugins/notification-resources/src/components/inbox/InboxFlatListView.svelte index 404a7dfd26..ac8312f25f 100644 --- a/plugins/notification-resources/src/components/inbox/InboxFlatListView.svelte +++ b/plugins/notification-resources/src/components/inbox/InboxFlatListView.svelte @@ -82,29 +82,27 @@ {@const notification = notifications[itemIndex]} - {#key notification._id} -
- - - - - - - - - - { - dispatch('click', { - context: $notifyContextsStore.find(({ _id }) => _id === notification.docNotifyContext), - notification - }) - }} - /> -
- {/key} +
+ + + + + + + + + + { + dispatch('click', { + context: $notifyContextsStore.find(({ _id }) => _id === notification.docNotifyContext), + notification + }) + }} + /> +
diff --git a/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte b/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte index 1c162f0985..d29639917f 100644 --- a/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte +++ b/plugins/notification-resources/src/components/inbox/InboxGroupedListView.svelte @@ -101,21 +101,19 @@ {@const contextId = displayData[itemIndex][0]} {@const contextNotifications = displayData[itemIndex][1]} {@const context = $notifyContextsStore.find(({ _id }) => _id === contextId)} - {#key contextId} - {#if context} - { - dispatch('click', event.detail) - listSelection = itemIndex - }} - on:check={(event) => handleCheck(context, event.detail)} - /> -
- {/if} - {/key} + {#if context} + { + dispatch('click', event.detail) + listSelection = itemIndex + }} + on:check={(event) => handleCheck(context, event.detail)} + /> +
+ {/if}