Merge branch 'master' into fix/import-column-issues

This commit is contained in:
Adria Navarro 2024-07-31 13:36:48 +02:00 committed by GitHub
commit 95b18076d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 27 deletions

View File

@ -100,51 +100,43 @@
async function handleFile(e) { async function handleFile(e) {
loading = true loading = true
error = null error = null
const previousValidation = validation
validation = {} validation = {}
try { try {
const response = await parseFile(e) const response = await parseFile(e)
rows = response.rows rows = response.rows
fileName = response.fileName fileName = response.fileName
const newValidateHash = JSON.stringify(rows)
if (newValidateHash === validateHash) {
validation = previousValidation
} else {
await validate(rows)
validateHash = newValidateHash
}
} catch (e) { } catch (e) {
error = e.message || e
} finally {
loading = false loading = false
error = e
} }
} }
async function validate(rows) { async function validate(rows) {
loading = true
error = null error = null
validation = {} validation = {}
allValid = false allValid = false
try { if (rows.length > 0) {
if (rows.length > 0) { const response = await API.validateExistingTableImport({
const response = await API.validateExistingTableImport({ rows,
rows, tableId,
tableId, })
})
validation = response.schemaValidation validation = response.schemaValidation
invalidColumns = response.invalidColumns invalidColumns = response.invalidColumns
allValid = response.allValid allValid = response.allValid
}
} catch (e) {
error = e.message
} }
loading = false
}
$: {
// binding in consumer is causing double renders here
const newValidateHash = JSON.stringify(rows)
if (newValidateHash !== validateHash) {
validate(rows)
}
validateHash = newValidateHash
} }
</script> </script>