From ceabc5573c4f7efbe684f1483c04e5184a2326bd Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 26 Dec 2024 19:38:33 +0100 Subject: [PATCH] Studio: fix #2316 --- src/UI/Base/If.svelte | 22 ++++++++++--------- .../TagRendering/TagRenderingQuestion.svelte | 7 +++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/UI/Base/If.svelte b/src/UI/Base/If.svelte index 2644653ec..5c87f6495 100644 --- a/src/UI/Base/If.svelte +++ b/src/UI/Base/If.svelte @@ -5,16 +5,18 @@ /** * For some stupid reason, it is very hard to let {#if} work together with UIEventSources, so we wrap then here */ - export let condition: Store - let _c = condition.data - onDestroy( - condition.addCallback((c) => { - /* Do _not_ abbreviate this as `.addCallback(c => _c = c)`. This is the same as writing `.addCallback(c => {return _c = c})`, - which will _unregister_ the callback if `c = true`! */ - _c = c - return false - }) - ) + export let condition: Store | undefined + let _c = condition?.data + if (condition !== undefined) { + onDestroy( + condition.addCallback((c) => { + /* Do _not_ abbreviate this as `.addCallback(c => _c = c)`. This is the same as writing `.addCallback(c => {return _c = c})`, + which will _unregister_ the callback if `c = true`! */ + _c = c + return false + }) + ) + } {#if _c} diff --git a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte index 2662ac7f1..bed0fd484 100644 --- a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte +++ b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte @@ -33,7 +33,6 @@ import Markdown from "../../Base/Markdown.svelte" import { Utils } from "../../../Utils" import type { UploadableTag } from "../../../Logic/Tags/TagTypes" - import { Modal } from "flowbite-svelte" import Popup from "../../Base/Popup.svelte" import If from "../../Base/If.svelte" import DotMenu from "../../Base/DotMenu.svelte" @@ -341,7 +340,7 @@ .catch(console.error) } - let disabledInTheme = state.userRelatedState.getThemeDisabled(state.theme.id, layer?.id) + let disabledInTheme = state.userRelatedState?.getThemeDisabled(state.theme.id, layer?.id) ?? new UIEventSource([]) let menuIsOpened = new UIEventSource(false) function disableQuestion() { @@ -361,7 +360,7 @@ {#if question !== undefined && $apiState !== "readonly" && $apiState !== "offline"}
- {#if layer.isNormal()} + {#if layer?.isNormal()} @@ -559,7 +558,7 @@ v === "yes" || v === "full" || v === "always" )} >