From e3a2d56afb343dd63936af9a15045c4dcad9eb15 Mon Sep 17 00:00:00 2001 From: brayn003 Date: Wed, 28 Aug 2024 18:57:01 +0800 Subject: [PATCH 1/4] fix: fixing issue with forking application --- app/client/src/ce/sagas/ApplicationSagas.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/client/src/ce/sagas/ApplicationSagas.tsx b/app/client/src/ce/sagas/ApplicationSagas.tsx index e529199407b..562c139376e 100644 --- a/app/client/src/ce/sagas/ApplicationSagas.tsx +++ b/app/client/src/ce/sagas/ApplicationSagas.tsx @@ -234,11 +234,7 @@ export function* fetchAppAndPagesSaga( ) { try { const { pages, ...payload } = action.payload; - const request = { - applicationId: payload.applicationId, - pageId: payload.pageId, - mode: payload.mode, - }; + const request = { ...payload }; if (request.pageId && request.applicationId) { delete request.applicationId; } From da839fe59b6feda354a57c0af1c9ca3159626064 Mon Sep 17 00:00:00 2001 From: brayn003 Date: Fri, 30 Aug 2024 01:45:39 +0800 Subject: [PATCH 2/4] fix: fixing absence of pageId --- app/client/src/pages/Editor/index.tsx | 37 +++++++++++++++------------ 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/app/client/src/pages/Editor/index.tsx b/app/client/src/pages/Editor/index.tsx index 8e02269316f..228ee33f9af 100644 --- a/app/client/src/pages/Editor/index.tsx +++ b/app/client/src/pages/Editor/index.tsx @@ -77,6 +77,8 @@ interface EditorProps { type Props = EditorProps & RouteComponentProps; class Editor extends Component { + prevPageId: string | null = null; + componentDidMount() { const { basePageId } = this.props.match.params || {}; urlBuilder.setCurrentBasePageId(basePageId); @@ -111,6 +113,21 @@ class Editor extends Component { componentDidUpdate(prevProps: Props) { const { baseApplicationId, basePageId } = this.props.match.params || {}; const { basePageId: prevPageBaseId } = prevProps.match.params || {}; + + const pageId = this.props.pages.find( + (page) => page.basePageId === basePageId, + )?.pageId; + + const prevPageId = prevProps.pages.find( + (page) => page.basePageId === prevPageBaseId, + )?.pageId; + // caching value for prevPageId as it is required in future lifecycles + if (!!prevPageId) { + this.prevPageId = prevPageId; + } + + const isPageIdUpdated = pageId !== this.prevPageId; + const isBranchUpdated = getIsBranchUpdated( this.props.location, prevProps.location, @@ -125,8 +142,6 @@ class Editor extends Component { GIT_BRANCH_QUERY_KEY, ); - const isPageIdUpdated = basePageId !== prevPageBaseId; - // to prevent re-init during connect if (prevBranch && isBranchUpdated && basePageId) { this.props.initEditor({ @@ -141,20 +156,10 @@ class Editor extends Component { * If we don't check for `prevPageId`: fetch page is re triggered * when redirected to the default page */ - if ( - prevPageBaseId && - basePageId && - isPageIdUpdated && - this.props.pages.length - ) { - const pageId = this.props.pages.find( - (page) => page.basePageId === basePageId, - )?.pageId; - if (pageId) { - this.props.updateCurrentPage(pageId); - this.props.setupPage(pageId); - urlBuilder.setCurrentBasePageId(basePageId); - } + if (pageId && this.prevPageId && isPageIdUpdated) { + this.props.updateCurrentPage(pageId); + this.props.setupPage(pageId); + urlBuilder.setCurrentBasePageId(basePageId); } } } From 6975416467eed7a774dd6e8b89315846f7d3ee38 Mon Sep 17 00:00:00 2001 From: brayn003 Date: Sun, 1 Sep 2024 21:43:08 +0800 Subject: [PATCH 3/4] fix: adding condition for basePageId and pageId --- app/client/src/pages/Editor/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/client/src/pages/Editor/index.tsx b/app/client/src/pages/Editor/index.tsx index 228ee33f9af..c1c7d08136e 100644 --- a/app/client/src/pages/Editor/index.tsx +++ b/app/client/src/pages/Editor/index.tsx @@ -112,14 +112,14 @@ class Editor extends Component { componentDidUpdate(prevProps: Props) { const { baseApplicationId, basePageId } = this.props.match.params || {}; - const { basePageId: prevPageBaseId } = prevProps.match.params || {}; + const { basePageId: prevBasePageId } = prevProps.match.params || {}; const pageId = this.props.pages.find( (page) => page.basePageId === basePageId, )?.pageId; const prevPageId = prevProps.pages.find( - (page) => page.basePageId === prevPageBaseId, + (page) => page.basePageId === prevBasePageId, )?.pageId; // caching value for prevPageId as it is required in future lifecycles if (!!prevPageId) { @@ -127,6 +127,8 @@ class Editor extends Component { } const isPageIdUpdated = pageId !== this.prevPageId; + const isBasePageIdUpdated = basePageId !== prevBasePageId; + const isPageUpdated = isPageIdUpdated || isBasePageIdUpdated; const isBranchUpdated = getIsBranchUpdated( this.props.location, @@ -156,7 +158,7 @@ class Editor extends Component { * If we don't check for `prevPageId`: fetch page is re triggered * when redirected to the default page */ - if (pageId && this.prevPageId && isPageIdUpdated) { + if (pageId && this.prevPageId && isPageUpdated) { this.props.updateCurrentPage(pageId); this.props.setupPage(pageId); urlBuilder.setCurrentBasePageId(basePageId); From 7f87f091b2d8810e3c0f875c3415aa8ff2aa7ba3 Mon Sep 17 00:00:00 2001 From: brayn003 Date: Mon, 2 Sep 2024 13:00:02 +0800 Subject: [PATCH 4/4] removed double negation --- app/client/src/pages/Editor/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/pages/Editor/index.tsx b/app/client/src/pages/Editor/index.tsx index c1c7d08136e..435f7e7f744 100644 --- a/app/client/src/pages/Editor/index.tsx +++ b/app/client/src/pages/Editor/index.tsx @@ -122,7 +122,7 @@ class Editor extends Component { (page) => page.basePageId === prevBasePageId, )?.pageId; // caching value for prevPageId as it is required in future lifecycles - if (!!prevPageId) { + if (prevPageId) { this.prevPageId = prevPageId; }