From 21caa45e653421572e1cbc13816c1f0278264835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sucena=20Lopes?= Date: Wed, 4 Dec 2024 17:27:35 +0000 Subject: [PATCH] refactor(picture input): reduce code inside 'if'-statement --- src/lib/components/forms/picture-input.svelte | 82 +++++++------------ 1 file changed, 29 insertions(+), 53 deletions(-) diff --git a/src/lib/components/forms/picture-input.svelte b/src/lib/components/forms/picture-input.svelte index ea56de5..0f7c607 100644 --- a/src/lib/components/forms/picture-input.svelte +++ b/src/lib/components/forms/picture-input.svelte @@ -11,65 +11,41 @@ let reader = new FileReader(); reader.readAsDataURL(image); reader.onload = (e) => { - avatar = e.target.result; + if (e.target?.result) { + avatar = e.target.result.toString(); + } }; };
- {#if avatar} -
+
+ {#if avatar} Avatar - - onFileSelected(e)} - bind:this={fileinput} - /> -
- {:else} -
+ {:else}

{text}*

- - onFileSelected(e)} - bind:this={fileinput} - /> -
- {/if} + } + }} + > + + + onFileSelected(e)} + bind:this={fileinput} + /> +