diff --git a/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte b/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte index f9fa56f739..399ec05b16 100644 --- a/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/ComponentSettingsSection.svelte @@ -7,6 +7,7 @@ import RoleSelect from "./PropertyControls/RoleSelect.svelte" import ResetFieldsButton from "./PropertyControls/ResetFieldsButton.svelte" import { getComponentForSettingType } from "./PropertyControls/componentSettings" + import { Utils } from "@budibase/frontend-core" export let componentDefinition export let componentInstance @@ -40,13 +41,13 @@ ] } - const updateProp = async (key, value) => { + const updateProp = Utils.sequential(async (key, value) => { try { await store.actions.components.updateProp(key, value) } catch (error) { notifications.error("Error updating component prop") } - } + }) const canRenderControl = setting => { const control = getComponentForSettingType(setting?.type) diff --git a/packages/frontend-core/src/index.js b/packages/frontend-core/src/index.js index 53822fdfb4..aecca81cda 100644 --- a/packages/frontend-core/src/index.js +++ b/packages/frontend-core/src/index.js @@ -1,7 +1,5 @@ export { createAPIClient } from "./api" -export { createLocalStorageStore } from "./stores/localStorage" export { fetchData } from "./fetch/fetchData" export * as Constants from "./constants" -export * as LuceneUtils from "./utils/lucene" -export * as JSONUtils from "./utils/json" -export * as CookieUtils from "./utils/cookies" +export * from "./stores" +export * from "./utils" diff --git a/packages/frontend-core/src/stores/index.js b/packages/frontend-core/src/stores/index.js new file mode 100644 index 0000000000..9766da43e3 --- /dev/null +++ b/packages/frontend-core/src/stores/index.js @@ -0,0 +1 @@ +export { createLocalStorageStore } from "./localStorage" diff --git a/packages/frontend-core/src/utils/index.js b/packages/frontend-core/src/utils/index.js new file mode 100644 index 0000000000..6755940289 --- /dev/null +++ b/packages/frontend-core/src/utils/index.js @@ -0,0 +1,4 @@ +export * as LuceneUtils from "./lucene" +export * as JSONUtils from "./json" +export * as CookieUtils from "./cookies" +export * as Utils from "./utils" diff --git a/packages/frontend-core/src/utils/utils.js b/packages/frontend-core/src/utils/utils.js new file mode 100644 index 0000000000..afa88a0624 --- /dev/null +++ b/packages/frontend-core/src/utils/utils.js @@ -0,0 +1,17 @@ +/** + * Utility to wrap an async function and ensure all invocations happen + * sequentially. + * @param fn the async function to run + * @return {Promise} a sequential version of the function + */ +export const sequential = fn => { + let promise + return async (...params) => { + if (promise) { + await promise + } + promise = fn(...params) + await promise + promise = null + } +}