From fa302c0bb01b4e81b13f1c8e77b471bbad3c955d Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 15 Mar 2022 13:02:45 +0530 Subject: [PATCH] hotfix: Edited changes not shown when switching versions (#2386) * fix edited changes not shown when switching versions * fix version create from not picking editing version * fix version switch not updated on editing version save --- frontend/src/Editor/AppVersionsManager.jsx | 11 +++++++++++ frontend/src/Editor/Editor.jsx | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend/src/Editor/AppVersionsManager.jsx b/frontend/src/Editor/AppVersionsManager.jsx index e6eae7dc1c..650c581977 100644 --- a/frontend/src/Editor/AppVersionsManager.jsx +++ b/frontend/src/Editor/AppVersionsManager.jsx @@ -36,6 +36,17 @@ export const AppVersionsManager = function AppVersionsManager({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + useEffect(() => { + setEditingAppVersion(editingVersion); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [editingVersion]); + + useEffect(() => { + appVersions[appVersions.findIndex((appVersion) => appVersion.id === editingVersion.id)] = editingAppVersion; + setCreateAppVersionFrom(editingAppVersion); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [editingAppVersion]); + const wrapperRef = useRef(null); useEffect(() => { const handleClickOutside = (event) => { diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index f04b291eec..4ec3e84e19 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -827,7 +827,14 @@ class Editor extends React.Component { } else if (!isEmpty(this.state.editingVersion)) { this.setState({ isSavingEditingVersion: true, showSaveDetail: true }); appVersionService.save(this.state.appId, this.state.editingVersion.id, this.state.appDefinition).then(() => { - this.setState({ isSavingEditingVersion: false }); + this.setState({ + isSavingEditingVersion: false, + editingVersion: { + ...this.state.editingVersion, + ...{ definition: this.state.appDefinition }, + }, + }); + setTimeout(() => this.setState({ showSaveDetail: false }), 3000); }); }