UBERF-8886 Fix presenter not found error (#7433)

This commit is contained in:
Alexander Onnikov 2024-12-12 09:46:44 +07:00 committed by GitHub
parent fbb3471a49
commit a62625f29f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<Ref<Class<Doc>>, 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<Ref<Class<Doc>>, 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