diff --git a/app/client/src/entities/Engine/AppEditorEngine.ts b/app/client/src/entities/Engine/AppEditorEngine.ts index fc8f608f8452..476d38231b40 100644 --- a/app/client/src/entities/Engine/AppEditorEngine.ts +++ b/app/client/src/entities/Engine/AppEditorEngine.ts @@ -3,7 +3,6 @@ import { resetEditorSuccess } from "actions/initActions"; import { fetchAllPageEntityCompletion, setupPageAction, - updateAppStore, } from "actions/pageActions"; import { executePageLoadActions, @@ -74,8 +73,8 @@ import { selectGitApplicationCurrentBranch, selectGitModEnabled, } from "selectors/gitModSelectors"; -import { getPersistentAppStore } from "constants/AppConstants"; import { applicationArtifact } from "git-artifact-helpers/application"; +import log from "loglevel"; export default class AppEditorEngine extends AppEngine { constructor(mode: APP_MODE) { @@ -303,23 +302,19 @@ export default class AppEditorEngine extends AppEngine { if (isGitPersistBranchEnabled) { const currentUser: User = yield select(getCurrentUser); - if (currentUser.email && currentApplication?.baseId && currentBranch) { + if (currentUser?.email && currentApplication?.baseId && currentBranch) { yield setLatestGitBranchInLocal( currentUser.email, currentApplication.baseId, currentBranch, ); + } else { + log.error( + `There was an error setting the latest git branch in local - userEmail: ${!!currentUser?.email}, applicationId: ${currentApplication?.baseId}, branch: ${currentBranch}`, + ); } } - if (currentApplication?.id) { - yield put( - updateAppStore( - getPersistentAppStore(currentApplication.id, currentBranch), - ), - ); - } - const [isAnotherEditorTabOpen, currentTabs] = yield call( trackOpenEditorTabs, currentApplication.id, diff --git a/app/client/src/entities/Engine/index.ts b/app/client/src/entities/Engine/index.ts index ef04f811c927..8fab09e8c1a6 100644 --- a/app/client/src/entities/Engine/index.ts +++ b/app/client/src/entities/Engine/index.ts @@ -1,5 +1,5 @@ import { fetchApplication } from "ee/actions/applicationActions"; -import { setAppMode } from "actions/pageActions"; +import { setAppMode, updateAppStore } from "actions/pageActions"; import type { ApplicationPayload } from "entities/Application"; import { ReduxActionErrorTypes, @@ -19,6 +19,8 @@ import { updateBranchLocally } from "actions/gitSyncActions"; import { restoreIDEEditorViewMode } from "actions/ideActions"; import type { Span } from "instrumentation/types"; import { endSpan, startNestedSpan } from "instrumentation/generateTraces"; +import { selectGitApplicationCurrentBranch } from "selectors/gitModSelectors"; +import { getPersistentAppStore } from "constants/AppConstants"; export interface AppEnginePayload { applicationId?: string; @@ -85,7 +87,7 @@ export default abstract class AppEngine { rootSpan: Span, ) { const loadAppDataSpan = startNestedSpan("AppEngine.loadAppData", rootSpan); - const { applicationId, basePageId } = payload; + const { applicationId, basePageId, branch } = payload; const { pages } = allResponses; const page = pages.data?.pages?.find((page) => page.baseId === basePageId); const apiCalls: boolean = yield failFastApiCalls( @@ -112,6 +114,15 @@ export default abstract class AppEngine { } const application: ApplicationPayload = yield select(getCurrentApplication); + const currentBranch: string | undefined = yield select( + selectGitApplicationCurrentBranch, + ); + + yield put( + updateAppStore( + getPersistentAppStore(application.id, branch || currentBranch), + ), + ); const defaultPageId: string = yield select(getDefaultPageId); const defaultPageBaseId: string = yield select(getDefaultBasePageId);