Small improvements in tabs opening (#5608)

Don't show in changelog
This commit is contained in:
AlexandreS
2023-08-29 16:22:03 +02:00
committed by GitHub
parent 90b830853a
commit d193b9375e
3 changed files with 34 additions and 11 deletions

View File

@@ -157,7 +157,11 @@ export const openEditorTab = (
return {
...state,
editors: [...state.editors, editorTab],
editors:
// Make sure the home page is always the first tab.
key === 'start page'
? [editorTab, ...state.editors]
: [...state.editors, editorTab],
currentTab: dontFocusTab ? state.currentTab : state.editors.length,
};
};

View File

@@ -112,10 +112,10 @@ const useEditorTabsStateSaving = ({
);
const openEditorTabsFromPersistedState = React.useCallback(
(project: gdProject) => {
(project: gdProject): number => {
const projectId = project.getProjectUuid();
const editorState = getEditorStateForProject(projectId);
if (!editorState) return;
if (!editorState) return 0;
let shouldOpenSavedCurrentTab = true;
const editorsOpeningOptions = editorState.editorTabs.editors
@@ -167,6 +167,7 @@ const useEditorTabsStateSaving = ({
: 0
);
setEditorTabs(newEditorTabs);
return editorsOpeningOptions.length;
},
[
getEditorOpeningOptions,

View File

@@ -1983,10 +1983,19 @@ const MainFrame = (props: Props) => {
currentProject &&
hasAPreviousSaveForEditorTabsState(currentProject)
) {
openEditorTabsFromPersistedState(currentProject);
setIsLoadingProject(false);
setLoaderModalProgress(null, null);
openProjectManager(false);
const openedEditorsCount = openEditorTabsFromPersistedState(
currentProject
);
if (openedEditorsCount === 0) {
openSceneOrProjectManager({
currentProject: currentProject,
editorTabs: state.editorTabs,
});
} else {
setIsLoadingProject(false);
setLoaderModalProgress(null, null);
openProjectManager(false);
}
} else {
openSceneOrProjectManager({
currentProject: currentProject,
@@ -2064,10 +2073,19 @@ const MainFrame = (props: Props) => {
currentProject &&
hasAPreviousSaveForEditorTabsState(currentProject)
) {
openEditorTabsFromPersistedState(currentProject);
setIsLoadingProject(false);
setLoaderModalProgress(null, null);
openProjectManager(false);
const openedEditorsCount = openEditorTabsFromPersistedState(
currentProject
);
if (openedEditorsCount === 0) {
openSceneOrProjectManager({
currentProject: currentProject,
editorTabs: state.editorTabs,
});
} else {
setIsLoadingProject(false);
setLoaderModalProgress(null, null);
openProjectManager(false);
}
} else {
openSceneOrProjectManager({
currentProject: currentProject,