From bac7a253c2dfcd7ef58be8baf4a8a4cfe3631685 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 20 Jul 2023 14:45:53 +0100 Subject: [PATCH] Fix the rest of the nasty flashing when working with importing CSVs --- .../TableNavigator/TableDataImport.svelte | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte index 5b43d6e2ed..0877ac201c 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte @@ -53,6 +53,15 @@ $: displayColumnOptions = Object.keys(schema || {}).filter(column => { return validation[column] }) + $: { + // binding in consumer is causing double renders here + const newValidateHash = JSON.stringify(rows) + JSON.stringify(schema) + if (newValidateHash !== validateHash) { + validate(rows, schema) + } + validateHash = newValidateHash + } + $: openFileUpload(promptUpload, fileInput) async function handleFile(e) { loading = true @@ -73,7 +82,6 @@ async function validate(rows, schema) { loading = true - try { if (rows.length > 0) { const response = await API.validateNewTableImport({ rows, schema }) @@ -88,21 +96,9 @@ allValid = false errors = {} } - loading = false } - $: { - // binding in consumer is causing double renders here - const newValidateHash = JSON.stringify(rows) + JSON.stringify(schema) - - if (newValidateHash !== validateHash) { - validate(rows, schema) - } - - validateHash = newValidateHash - } - const handleChange = (name, e) => { schema[name].type = e.detail schema[name].constraints = FIELDS[e.detail.toUpperCase()].constraints @@ -114,7 +110,13 @@ } } - $: openFileUpload(promptUpload, fileInput) + const deleteColumn = name => { + if (loading) { + return + } + delete schema[name] + schema = schema + }
@@ -127,10 +129,8 @@ on:change={handleFile} />
{/each}