From bd05db68d2dc2ca3a3032fe7e15c69bd7e7c78d9 Mon Sep 17 00:00:00 2001 From: arpitnath Date: Fri, 29 Sep 2023 19:12:04 +0530 Subject: [PATCH] fixes: CSA for button(component) does not work for page event handler. --- frontend/src/Editor/EditorFunc.jsx | 12 +----------- frontend/src/_helpers/appUtils.js | 5 ++++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/frontend/src/Editor/EditorFunc.jsx b/frontend/src/Editor/EditorFunc.jsx index 4bc322c3c8..2f8313e62a 100644 --- a/frontend/src/Editor/EditorFunc.jsx +++ b/frontend/src/Editor/EditorFunc.jsx @@ -199,15 +199,6 @@ const EditorComponent = (props) => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - // Ref to store the previous appDefinition for comparison - - useEffect(() => { - if (mounted && currentUser?.current_organization_id) { - fetchGlobalDataSources(); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [JSON.stringify(currentUser?.current_organization_id)]); - // Handle appDefinition updates useEffect(() => { const didAppDefinitionChanged = !_.isEqual(appDefinition, prevAppDefinition.current); @@ -670,10 +661,9 @@ const EditorComponent = (props) => { isUpdatingEditorStateInProcess: false, }); + await useDataSourcesStore.getState().actions.fetchGlobalDataSources(data?.organization_id); await fetchDataSources(data.editing_version?.id); await fetchDataQueries(data.editing_version?.id, true, true); - await fetchGlobalDataSources(); - const currentPageEvents = data.events.filter((event) => event.target === 'page' && event.sourceId === homePageId); for (const currentEvent of currentPageEvents ?? []) { diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index c285cf3259..fd35c17252 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -616,7 +616,10 @@ export async function onEvent(_ref, eventName, events, options = {}, mode = 'edi const { customVariables } = options; if (eventName === 'onPageLoad') { - await executeActionsForEventId(_ref, 'onPageLoad', events, mode, customVariables); + //hack to make sure that the page is loaded before executing the actions + setTimeout(async () => { + return await executeActionsForEventId(_ref, 'onPageLoad', events, mode, customVariables); + }, 0); } if (eventName === 'onTrigger') {