This commit is contained in:
Pieter Vander Vennet 2024-12-26 19:38:33 +01:00
parent ff53354c96
commit ceabc5573c
2 changed files with 15 additions and 14 deletions

View file

@ -5,16 +5,18 @@
/** /**
* For some stupid reason, it is very hard to let {#if} work together with UIEventSources, so we wrap then here * For some stupid reason, it is very hard to let {#if} work together with UIEventSources, so we wrap then here
*/ */
export let condition: Store<boolean> export let condition: Store<boolean> | undefined
let _c = condition.data let _c = condition?.data
onDestroy( if (condition !== undefined) {
condition.addCallback((c) => { onDestroy(
/* Do _not_ abbreviate this as `.addCallback(c => _c = c)`. This is the same as writing `.addCallback(c => {return _c = c})`, condition.addCallback((c) => {
which will _unregister_ the callback if `c = true`! */ /* Do _not_ abbreviate this as `.addCallback(c => _c = c)`. This is the same as writing `.addCallback(c => {return _c = c})`,
_c = c which will _unregister_ the callback if `c = true`! */
return false _c = c
}) return false
) })
)
}
</script> </script>
{#if _c} {#if _c}

View file

@ -33,7 +33,6 @@
import Markdown from "../../Base/Markdown.svelte" import Markdown from "../../Base/Markdown.svelte"
import { Utils } from "../../../Utils" import { Utils } from "../../../Utils"
import type { UploadableTag } from "../../../Logic/Tags/TagTypes" import type { UploadableTag } from "../../../Logic/Tags/TagTypes"
import { Modal } from "flowbite-svelte"
import Popup from "../../Base/Popup.svelte" import Popup from "../../Base/Popup.svelte"
import If from "../../Base/If.svelte" import If from "../../Base/If.svelte"
import DotMenu from "../../Base/DotMenu.svelte" import DotMenu from "../../Base/DotMenu.svelte"
@ -341,7 +340,7 @@
.catch(console.error) .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<string[]>([])
let menuIsOpened = new UIEventSource(false) let menuIsOpened = new UIEventSource(false)
function disableQuestion() { function disableQuestion() {
@ -361,7 +360,7 @@
{#if question !== undefined && $apiState !== "readonly" && $apiState !== "offline"} {#if question !== undefined && $apiState !== "readonly" && $apiState !== "offline"}
<div class={clss}> <div class={clss}>
{#if layer.isNormal()} {#if layer?.isNormal()}
<LoginToggle {state}> <LoginToggle {state}>
<DotMenu hideBackground={true} open={menuIsOpened}> <DotMenu hideBackground={true} open={menuIsOpened}>
<SidebarUnit> <SidebarUnit>
@ -559,7 +558,7 @@
</h2> </h2>
<Tr t={Translations.t.unknown.explanation} /> <Tr t={Translations.t.unknown.explanation} />
<If <If
condition={state.userRelatedState.showTags.map( condition={state.userRelatedState?.showTags?.map(
(v) => v === "yes" || v === "full" || v === "always" (v) => v === "yes" || v === "full" || v === "always"
)} )}
> >