diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index d05f01f58a..3ee288a8b6 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -9,7 +9,7 @@ import Router from "./Router.svelte" import { enrichProps, propsAreSame } from "utils/componentProps" import { builderStore } from "stores" - import { hashString } from "utils/helpers" + import { Helpers } from "@budibase/frontend-core" import Manifest from "manifest.json" import { getActiveConditions, reduceConditionActions } from "utils/conditions" import Placeholder from "components/app/Placeholder.svelte" @@ -106,7 +106,7 @@ // Raw settings are all settings excluding internal props and children $: rawSettings = getRawSettings(instance) - $: instanceKey = hashString(JSON.stringify(rawSettings)) + $: instanceKey = Helpers.hashString(JSON.stringify(rawSettings)) // Update and enrich component settings $: updateSettings(rawSettings, instanceKey, settingsDefinition, $context) @@ -300,7 +300,7 @@ // Generates a key used to determine when components need to fully remount. // Currently only toggling editing requires remounting. const getRenderKey = (id, editing) => { - return hashString(`${id}-${editing}`) + return Helpers.hashString(`${id}-${editing}`) } diff --git a/packages/client/src/components/app/forms/AttachmentField.svelte b/packages/client/src/components/app/forms/AttachmentField.svelte index a5eec03ac4..679dfa9702 100644 --- a/packages/client/src/components/app/forms/AttachmentField.svelte +++ b/packages/client/src/components/app/forms/AttachmentField.svelte @@ -29,10 +29,14 @@ for (let i = 0; i < fileList.length; i++) { data.append("file", fileList[i]) } - return await API.uploadAttachment({ - data, - tableId: formContext?.dataSource?.tableId, - }) + try { + return await API.uploadAttachment({ + data, + tableId: formContext?.dataSource?.tableId, + }) + } catch (error) { + return [] + } } diff --git a/packages/client/src/components/app/forms/Form.svelte b/packages/client/src/components/app/forms/Form.svelte index 505c45bde0..134ca169a5 100644 --- a/packages/client/src/components/app/forms/Form.svelte +++ b/packages/client/src/components/app/forms/Form.svelte @@ -1,7 +1,7 @@ diff --git a/packages/client/src/components/app/forms/InnerForm.svelte b/packages/client/src/components/app/forms/InnerForm.svelte index c1e92bf442..1d8bca2179 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -2,7 +2,7 @@ import { setContext, getContext } from "svelte" import { derived, get, writable } from "svelte/store" import { createValidatorFromConstraints } from "./validation" - import { generateID } from "utils/helpers" + import { Helpers } from "@budibase/frontend-core" import { deepGet, deepSet } from "@budibase/bbui" import { cloneDeep } from "lodash/fp" @@ -153,7 +153,7 @@ // If we've already registered this field then keep some existing state let initialValue = deepGet(initialValues, field) ?? defaultValue let initialError = null - let fieldId = `id-${generateID()}` + let fieldId = `id-${Helpers.uuid()}` const existingField = getField(field) if (existingField) { const { fieldState } = get(existingField) diff --git a/packages/client/src/components/app/forms/RelationshipField.svelte b/packages/client/src/components/app/forms/RelationshipField.svelte index dbf708f893..bd8a086dfd 100644 --- a/packages/client/src/components/app/forms/RelationshipField.svelte +++ b/packages/client/src/components/app/forms/RelationshipField.svelte @@ -30,17 +30,21 @@ const fetchTable = async id => { if (id) { - const result = await API.fetchTableDefinition(id) - if (!result.error) { - tableDefinition = result + try { + tableDefinition = await API.fetchTableDefinition(id) + } catch (error) { + tableDefinition = null } } } const fetchRows = async id => { if (id) { - const rows = await API.fetchTableData(id) - options = rows && !rows.error ? rows : [] + try { + options = await API.fetchTableData(id) + } catch (error) { + options = [] + } } }