fixes: editor crash on switching versions from viewer

This commit is contained in:
arpitnath 2024-04-11 11:35:18 +05:30
parent a12ca9fed8
commit 4745d0019c
2 changed files with 15 additions and 2 deletions

View file

@ -244,6 +244,8 @@ export const Container = ({
return;
}
if (!appDefinition.pages[currentPageId]?.components) return;
const newDefinition = {
...appDefinition,
pages: {
@ -251,7 +253,7 @@ export const Container = ({
[currentPageId]: {
...appDefinition.pages[currentPageId],
components: {
...appDefinition.pages[currentPageId].components,
...appDefinition.pages[currentPageId]?.components,
...boxes,
},
},

View file

@ -709,7 +709,18 @@ class ViewerComponent extends React.Component {
};
handleEvent = (eventName, events, options) => {
return onEvent(this.getViewerRef(), eventName, events, options, 'view');
const latestEvents = useAppDataStore.getState().events;
const filteredEvents = latestEvents.filter((event) => {
const foundEvent = events.find((e) => e.id === event.id);
return foundEvent && foundEvent.name === eventName;
});
try {
return onEvent(this.getViewerRef(), eventName, filteredEvents, options, 'view');
} catch (error) {
console.error(error);
}
};
computeCanvasMaxWidth = () => {