From a62625f29f31e1fa1310ca88556cb90df70e5596 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Thu, 12 Dec 2024 09:46:44 +0700 Subject: [PATCH] UBERF-8886 Fix presenter not found error (#7433) --- .../src/components/ViewletContentView.svelte | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/view-resources/src/components/ViewletContentView.svelte b/plugins/view-resources/src/components/ViewletContentView.svelte index b04b54c6e4..369e3ab127 100644 --- a/plugins/view-resources/src/components/ViewletContentView.svelte +++ b/plugins/view-resources/src/components/ViewletContentView.svelte @@ -22,12 +22,18 @@ const preferenceQuery = createQuery() const objectConfigurations = createQuery() let preference: ViewletPreference[] = [] - let loading = true + + let configurationsLoading = true + let preferencesLoading = true + $: loading = configurationsLoading || preferencesLoading let configurationRaw: Viewlet[] = [] let configurations: Record>, Viewlet['config']> = {} - $: viewlet && + function fetchConfigurations (viewlet: Viewlet): void { + configurationsLoading = true + configurations = {} + objectConfigurations.query( view.class.Viewlet, { @@ -37,11 +43,13 @@ }, (res) => { configurationRaw = res - loading = false + configurationsLoading = false } ) + } - $: viewlet && + function fetchPreferences (viewlet: Viewlet): void { + preferencesLoading = true preferenceQuery.query( view.class.ViewletPreference, { @@ -50,9 +58,10 @@ }, (res) => { preference = res - loading = false + preferencesLoading = false } ) + } function updateConfiguration (configurationRaw: Viewlet[], preference: ViewletPreference[]): void { const newConfigurations: Record>, Viewlet['config']> = {} @@ -74,6 +83,9 @@ configurations = newConfigurations } + $: fetchConfigurations(viewlet) + $: fetchPreferences(viewlet) + $: updateConfiguration(configurationRaw, preference) $: config = preference.find((it) => it.attachedTo === viewlet._id)?.config ?? viewlet.config