Skip to content

Commit

Permalink
Fix project not opening after reopening IDE when on Local backend (#9465
Browse files Browse the repository at this point in the history
)

- Fix #9455
- Also fix minor issue where disabled `Button`s had `cursor: pointer`.

# Important Notes
None
  • Loading branch information
somebody1234 authored Mar 19, 2024
1 parent 6e5b4d9 commit dfaab53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
7 changes: 5 additions & 2 deletions app/ide-desktop/lib/dashboard/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ export default function Button(props: ButtonProps) {
const { alt, className, onClick } = props

return (
<button disabled={disabled} className={`group flex selectable ${active ? 'active' : ''}`}>
<button
disabled={disabled}
className={`group flex selectable ${active ? 'active' : ''}`}
onClick={onClick}
>
<SvgMask
src={image}
{...(!active && disabled && error != null ? { title: error } : {})}
{...(alt != null ? { alt } : {})}
className={className}
onClick={onClick}
/>
</button>
)
Expand Down
35 changes: 15 additions & 20 deletions app/ide-desktop/lib/dashboard/src/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export interface DashboardProps {

/** The component that contains the entire UI. */
export default function Dashboard(props: DashboardProps) {
const { supportsLocalBackend, appRunner, initialProjectName: rawInitialProjectName } = props
const { supportsLocalBackend, appRunner, initialProjectName } = props
const { projectManagerUrl } = props
const logger = loggerProvider.useLogger()
const session = authProvider.useNonPartialUserSession()
Expand Down Expand Up @@ -140,7 +140,6 @@ export default function Dashboard(props: DashboardProps) {
() => localStorage.get('isAssetPanelVisible') ?? false
)
const [isAssetPanelTemporarilyVisible, setIsAssetPanelTemporarilyVisible] = React.useState(false)
const [initialProjectName, setInitialProjectName] = React.useState(rawInitialProjectName)
const isCloud = backend.type === backendModule.BackendType.remote
const rootDirectoryId = React.useMemo(
() => session.user?.rootDirectoryId ?? backendModule.DirectoryId(''),
Expand Down Expand Up @@ -176,7 +175,7 @@ export default function Dashboard(props: DashboardProps) {
setBackend(currentBackend)
}
const savedProjectStartupInfo = localStorage.get('projectStartupInfo')
if (rawInitialProjectName != null) {
if (initialProjectName != null) {
if (page === pageSwitcher.Page.editor) {
setPage(pageSwitcher.Page.drive)
}
Expand Down Expand Up @@ -235,23 +234,19 @@ export default function Dashboard(props: DashboardProps) {
}
}
} else {
if (currentBackend.type === backendModule.BackendType.local) {
setInitialProjectName(savedProjectStartupInfo.projectAsset.id)
} else {
const localBackend = new LocalBackend(projectManagerUrl)
void (async () => {
await localBackend.openProject(
savedProjectStartupInfo.projectAsset.id,
null,
savedProjectStartupInfo.projectAsset.title
)
const project = await localBackend.getProjectDetails(
savedProjectStartupInfo.projectAsset.id,
savedProjectStartupInfo.projectAsset.title
)
setProjectStartupInfo(object.merge(savedProjectStartupInfo, { project }))
})()
}
const localBackend = new LocalBackend(projectManagerUrl)
void (async () => {
await localBackend.openProject(
savedProjectStartupInfo.projectAsset.id,
null,
savedProjectStartupInfo.projectAsset.title
)
const project = await localBackend.getProjectDetails(
savedProjectStartupInfo.projectAsset.id,
savedProjectStartupInfo.projectAsset.title
)
setProjectStartupInfo(object.merge(savedProjectStartupInfo, { project }))
})()
}
}
// This MUST only run when the component is mounted.
Expand Down

0 comments on commit dfaab53

Please sign in to comment.