From 007f05f0d96ff5ba6e1760495e8ac213541edd3b Mon Sep 17 00:00:00 2001 From: arpitnath Date: Sun, 17 Sep 2023 00:02:22 +0530 Subject: [PATCH] fixes: event execution for viewer --- frontend/src/Editor/Viewer.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/Editor/Viewer.jsx b/frontend/src/Editor/Viewer.jsx index 518cfa6f55..98f804f754 100644 --- a/frontend/src/Editor/Viewer.jsx +++ b/frontend/src/Editor/Viewer.jsx @@ -46,6 +46,7 @@ import { setCookie } from '@/_helpers/cookie'; import { useDataQueriesStore } from '@/_stores/dataQueriesStore'; import { useCurrentStateStore } from '@/_stores/currentStateStore'; import { shallow } from 'zustand/shallow'; +import { useAppDataActions } from '@/_stores/appDataStore'; class ViewerComponent extends React.Component { constructor(props) { @@ -74,7 +75,6 @@ class ViewerComponent extends React.Component { errorVersionId: null, errorDetails: null, pages: {}, - events: [], homepage: null, currentPageId: null, }; @@ -167,6 +167,7 @@ class ViewerComponent extends React.Component { ...constants, }); useEditorStore.getState().actions.toggleCurrentLayout(mobileLayoutHasWidgets ? 'mobile' : 'desktop'); + this.props.updateState({ events: data.events ?? [] }); this.setState( { currentUser, @@ -182,7 +183,6 @@ class ViewerComponent extends React.Component { currentPageId: currentPage.id, pages: {}, homepage: appDefData?.pages?.[this.state.appDefinition?.homePageId]?.handle, - events: data.events ?? [], }, () => { const components = appDefData?.pages[currentPageId]?.components || {}; @@ -548,6 +548,7 @@ class ViewerComponent extends React.Component { switchPage: this.switchPage, currentPageId: currentPageId, }; + onEvent(viewerRef, eventName, event, options, 'view'); }; @@ -752,12 +753,15 @@ const withStore = (Component) => (props) => { shallow ); + const { updateState } = useAppDataActions(); + return ( ); };