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 { return {
...state, ...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, currentTab: dontFocusTab ? state.currentTab : state.editors.length,
}; };
}; };

View File

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

View File

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