mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 07:12:20 +03:00
Fix unsetting saved project on close (#7661)
Extracted from #7660. Fixes the bug that happens when you do: - Open the app with a saved "last opened project" - The app will immediately restore the project - Close the project - Reopen/reload the app - The same project will start opening again. - Expected behavior: The project does not start, because it was previously manually closed. # Important Notes None
This commit is contained in:
parent
f6225882ed
commit
01aab4a2cc
@ -10,6 +10,8 @@ import * as assetEventModule from '../events/assetEvent'
|
||||
import * as backendModule from '../backend'
|
||||
import * as backendProvider from '../../providers/backend'
|
||||
import * as hooks from '../../hooks'
|
||||
import * as localStorageModule from '../localStorage'
|
||||
import * as localStorageProvider from '../../providers/localStorage'
|
||||
import * as modalProvider from '../../providers/modal'
|
||||
import * as remoteBackend from '../remoteBackend'
|
||||
|
||||
@ -78,6 +80,7 @@ export default function ProjectIcon(props: ProjectIconProps) {
|
||||
} = props
|
||||
const { backend } = backendProvider.useBackend()
|
||||
const { unsetModal } = modalProvider.useSetModal()
|
||||
const { localStorage } = localStorageProvider.useLocalStorage()
|
||||
const toastAndLog = hooks.useToastAndLog()
|
||||
const state = item.projectState.type
|
||||
const setState = React.useCallback(
|
||||
@ -245,6 +248,10 @@ export default function ProjectIcon(props: ProjectIconProps) {
|
||||
}, [shouldOpenWhenReady, shouldSwitchPage, state, openIde])
|
||||
|
||||
const closeProject = async (triggerOnClose = true) => {
|
||||
if (triggerOnClose) {
|
||||
onClose()
|
||||
localStorage.delete(localStorageModule.LocalStorageKey.projectStartupInfo)
|
||||
}
|
||||
setToastId(null)
|
||||
setShouldOpenWhenReady(false)
|
||||
setState(backendModule.ProjectState.closing)
|
||||
@ -257,9 +264,6 @@ export default function ProjectIcon(props: ProjectIconProps) {
|
||||
state !== backendModule.ProjectState.closing &&
|
||||
state !== backendModule.ProjectState.closed
|
||||
) {
|
||||
if (triggerOnClose) {
|
||||
onClose()
|
||||
}
|
||||
try {
|
||||
if (
|
||||
backend.type === backendModule.BackendType.local &&
|
||||
|
Loading…
Reference in New Issue
Block a user