From e11c6dca75d3986b59b535862402211fcefe0c2a Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Sun, 14 Dec 2025 12:12:57 -0500 Subject: [PATCH] fix(model-editor): add null safety for tools, functions, and file input (#19939) --- .../workspace/Models/ModelEditor.svelte | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/components/workspace/Models/ModelEditor.svelte b/src/lib/components/workspace/Models/ModelEditor.svelte index 636048e8c7..ad164c0bdb 100644 --- a/src/lib/components/workspace/Models/ModelEditor.svelte +++ b/src/lib/components/workspace/Models/ModelEditor.svelte @@ -361,7 +361,7 @@ on:change={() => { let reader = new FileReader(); reader.onload = (event) => { - let originalImageUrl = `${event.target.result}`; + let originalImageUrl = `${event.target?.result}`; const img = new Image(); img.src = originalImageUrl; @@ -409,12 +409,12 @@ inputFiles && inputFiles.length > 0 && ['image/gif', 'image/webp', 'image/jpeg', 'image/png', 'image/svg+xml'].includes( - inputFiles[0]['type'] + (inputFiles[0] as any)?.['type'] ) ) { reader.readAsDataURL(inputFiles[0]); } else { - console.log(`Unsupported File Type '${inputFiles[0]['type']}'.`); + console.log(`Unsupported File Type '${(inputFiles[0] as any)?.['type']}'.`); inputFiles = null; } }} @@ -713,22 +713,22 @@
- +
- {#if $functions.filter((func) => func.type === 'filter').length > 0 || $functions.filter((func) => func.type === 'action').length > 0} + {#if ($functions ?? []).filter((func) => func.type === 'filter').length > 0 || ($functions ?? []).filter((func) => func.type === 'action').length > 0}
- {#if $functions.filter((func) => func.type === 'filter').length > 0} + {#if ($functions ?? []).filter((func) => func.type === 'filter').length > 0}
func.type === 'filter')} + filters={($functions ?? []).filter((func) => func.type === 'filter')} />
{#if filterIds.length > 0} - {@const toggleableFilters = $functions.filter( + {@const toggleableFilters = ($functions ?? []).filter( (func) => func.type === 'filter' && (filterIds.includes(func.id) || func?.is_global) && @@ -746,11 +746,11 @@ {/if} {/if} - {#if $functions.filter((func) => func.type === 'action').length > 0} + {#if ($functions ?? []).filter((func) => func.type === 'action').length > 0}
func.type === 'action')} + actions={($functions ?? []).filter((func) => func.type === 'action')} />
{/if}