fixes: CSA for button(component) does not work for page event handler.

This commit is contained in:
arpitnath 2023-09-29 19:12:04 +05:30
parent 066c369c63
commit bd05db68d2
2 changed files with 5 additions and 12 deletions

View file

@ -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 ?? []) {

View file

@ -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') {