fix: we are so back
This commit is contained in:
@ -9,23 +9,15 @@ import {
|
||||
} from 'react-router-dom'
|
||||
|
||||
import { App } from '@src/App'
|
||||
import { AppStateProvider } from '@src/AppState'
|
||||
import { Auth } from '@src/Auth'
|
||||
import { CommandBar } from '@src/components/CommandBar/CommandBar'
|
||||
import DownloadAppBanner from '@src/components/DownloadAppBanner'
|
||||
import { ErrorPage } from '@src/components/ErrorPage'
|
||||
import FileMachineProvider from '@src/components/FileMachineProvider'
|
||||
import LspProvider from '@src/components/LspProvider'
|
||||
import { MachineManagerProvider } from '@src/components/MachineManagerProvider'
|
||||
import ModelingMachineProvider from '@src/components/ModelingMachineProvider'
|
||||
import { OpenInDesktopAppHandler } from '@src/components/OpenInDesktopAppHandler'
|
||||
import { ProjectsContextProvider } from '@src/components/ProjectsContextProvider'
|
||||
import { SystemIOMachineLogicListener } from '@src/components/Providers/SystemIOProviderDesktop'
|
||||
import { RouteProvider } from '@src/components/RouteProvider'
|
||||
import { WasmErrBanner } from '@src/components/WasmErrBanner'
|
||||
import { NetworkContext } from '@src/hooks/useNetworkContext'
|
||||
import { useNetworkStatus } from '@src/hooks/useNetworkStatus'
|
||||
import { KclContextProvider } from '@src/lang/KclProvider'
|
||||
import { coreDump } from '@src/lang/wasm'
|
||||
import {
|
||||
ASK_TO_OPEN_QUERY_PARAM,
|
||||
@ -44,23 +36,23 @@ import {
|
||||
} from '@src/lib/singletons'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
import { useToken } from '@src/machines/appMachine'
|
||||
import RootLayout from '@src/Root'
|
||||
import Home from '@src/routes/Home'
|
||||
import Onboarding, { onboardingRoutes } from '@src/routes/Onboarding'
|
||||
import { Settings } from '@src/routes/Settings'
|
||||
import SignIn from '@src/routes/SignIn'
|
||||
import { Telemetry } from '@src/routes/Telemetry'
|
||||
import RootLayout from "@src/Root"
|
||||
|
||||
const createRouter = isDesktop() ? createHashRouter : createBrowserRouter
|
||||
|
||||
const router = createRouter([
|
||||
{
|
||||
id: PATHS.INDEX,
|
||||
element: <RootLayout/>,
|
||||
errorElement: <ErrorPage />,
|
||||
element: <RootLayout />,
|
||||
children: [
|
||||
{
|
||||
path: PATHS.INDEX,
|
||||
errorElement: <ErrorPage />,
|
||||
loader: async ({ request }) => {
|
||||
const onDesktop = isDesktop()
|
||||
const url = new URL(request.url)
|
||||
@ -81,6 +73,7 @@ const router = createRouter([
|
||||
loader: fileLoader,
|
||||
id: PATHS.FILE,
|
||||
path: PATHS.FILE + '/:id',
|
||||
errorElement: <ErrorPage />,
|
||||
element: (
|
||||
<Auth>
|
||||
<FileMachineProvider>
|
||||
@ -127,6 +120,7 @@ const router = createRouter([
|
||||
},
|
||||
{
|
||||
path: PATHS.HOME,
|
||||
errorElement: <ErrorPage />,
|
||||
element: (
|
||||
<Auth>
|
||||
<Outlet />
|
||||
@ -155,6 +149,7 @@ const router = createRouter([
|
||||
},
|
||||
{
|
||||
path: PATHS.SIGN_IN,
|
||||
errorElement: <ErrorPage />,
|
||||
element: <SignIn />,
|
||||
},
|
||||
],
|
||||
|
@ -229,7 +229,7 @@ const ProjectsContextDesktop = ({
|
||||
const newPathName = `${PATHS.FILE}/${encodeURIComponent(
|
||||
projectPath
|
||||
)}`
|
||||
console.log(newPathName,'asdf')
|
||||
console.log(newPathName, 'asdf')
|
||||
navigate(newPathName)
|
||||
}
|
||||
},
|
||||
|
@ -3,24 +3,25 @@ import { systemIOActor } from '@src/machines/appMachine'
|
||||
import { useSelector } from '@xstate/react'
|
||||
import { useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import {
|
||||
NO_PROJECT_DIRECTORY,
|
||||
SystemIOMachineEvents
|
||||
} from '@src/machines/systemIO/utils'
|
||||
export const useRequestedProjectName = () => useSelector(systemIOActor, (state) => state.context.requestedProjectName)
|
||||
export const useProjectDirectoryPath = () => useSelector(systemIOActor, (state) => state.context.projectDirectoryPath)
|
||||
|
||||
export const useRequestedProjectName = () =>
|
||||
useSelector(systemIOActor, (state) => state.context.requestedProjectName)
|
||||
export const useProjectDirectoryPath = () =>
|
||||
useSelector(systemIOActor, (state) => state.context.projectDirectoryPath)
|
||||
|
||||
export function SystemIOMachineLogicListener() {
|
||||
const requestedProjectName = useRequestedProjectName()
|
||||
const projectDirectoryPath = useProjectDirectoryPath()
|
||||
const navigate = useNavigate()
|
||||
useEffect(() => {
|
||||
if (!requestedProjectName.name) {return}
|
||||
if (!requestedProjectName.name) {
|
||||
return
|
||||
}
|
||||
let projectPathWithoutSpecificKCLFile =
|
||||
projectDirectoryPath + window.electron.path.sep + requestedProjectName.name
|
||||
projectDirectoryPath +
|
||||
window.electron.path.sep +
|
||||
requestedProjectName.name
|
||||
const requestedPath = `${PATHS.FILE}/${encodeURIComponent(
|
||||
projectPathWithoutSpecificKCLFile
|
||||
projectPathWithoutSpecificKCLFile
|
||||
)}`
|
||||
navigate(requestedPath)
|
||||
}, [requestedProjectName])
|
||||
|
@ -13,7 +13,7 @@ import { settingsMachine } from '@src/machines/settingsMachine'
|
||||
import { systemIOMachineDesktop } from '@src/machines/systemIO/systemIOMachineDesktop'
|
||||
import { SystemIOMachineEvents } from '@src/machines/systemIO/utils'
|
||||
|
||||
const { AUTH, SETTINGS, SYSTEM_IO, ENGINE_STREAM} = ACTOR_IDS
|
||||
const { AUTH, SETTINGS, SYSTEM_IO, ENGINE_STREAM } = ACTOR_IDS
|
||||
const appMachineActors = {
|
||||
[AUTH]: authMachine,
|
||||
[SETTINGS]: settingsMachine,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { DEFAULT_PROJECT_NAME } from '@src/lib/constants'
|
||||
import type { Project } from '@src/lib/project'
|
||||
import type {
|
||||
SystemIOContext} from '@src/machines/systemIO/utils'
|
||||
import type { SystemIOContext } from '@src/machines/systemIO/utils'
|
||||
import {
|
||||
NO_PROJECT_DIRECTORY,
|
||||
SystemIOMachineActions,
|
||||
@ -37,7 +36,7 @@ export const systemIOMachine = setup({
|
||||
| {
|
||||
type: SystemIOMachineEvents.openProject
|
||||
data: { requestedProjectName: string }
|
||||
}
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
[SystemIOMachineActions.setFolders]: assign({
|
||||
@ -58,7 +57,7 @@ export const systemIOMachine = setup({
|
||||
[SystemIOMachineActions.setRequestedProjectName]: assign({
|
||||
requestedProjectName: ({ event }) => {
|
||||
assertEvent(event, SystemIOMachineEvents.openProject)
|
||||
return {name:event.data.requestedProjectName}
|
||||
return { name: event.data.requestedProjectName }
|
||||
},
|
||||
}),
|
||||
},
|
||||
@ -79,7 +78,7 @@ export const systemIOMachine = setup({
|
||||
defaultProjectFolderName: DEFAULT_PROJECT_NAME,
|
||||
projectDirectoryPath: NO_PROJECT_DIRECTORY,
|
||||
hasListedProjects: false,
|
||||
requestedProjectName: {name:NO_PROJECT_DIRECTORY},
|
||||
requestedProjectName: { name: NO_PROJECT_DIRECTORY },
|
||||
}),
|
||||
states: {
|
||||
[SystemIOMachineStates.idle]: {
|
||||
@ -112,8 +111,7 @@ export const systemIOMachine = setup({
|
||||
},
|
||||
},
|
||||
},
|
||||
[SystemIOMachineStates.openingProject] : {
|
||||
}
|
||||
[SystemIOMachineStates.openingProject]: {},
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { getProjectInfo, mkdirOrNOOP } from '@src/lib/desktop'
|
||||
import type { Project } from '@src/lib/project'
|
||||
import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
||||
import type {
|
||||
SystemIOContext} from '@src/machines/systemIO/utils'
|
||||
import type { SystemIOContext } from '@src/machines/systemIO/utils'
|
||||
import {
|
||||
NO_PROJECT_DIRECTORY,
|
||||
SystemIOMachineActors,
|
||||
|
@ -1,10 +1,7 @@
|
||||
import type { Project } from '@src/lib/project'
|
||||
import { systemIOMachine } from '@src/machines/systemIO/systemIOMachine'
|
||||
import type {
|
||||
SystemIOContext} from '@src/machines/systemIO/utils'
|
||||
import {
|
||||
SystemIOMachineActors,
|
||||
} from '@src/machines/systemIO/utils'
|
||||
import type { SystemIOContext } from '@src/machines/systemIO/utils'
|
||||
import { SystemIOMachineActors } from '@src/machines/systemIO/utils'
|
||||
import { fromPromise } from 'xstate'
|
||||
|
||||
export const systemIOMachineWeb = systemIOMachine.provide({
|
||||
|
@ -9,7 +9,7 @@ export enum SystemIOMachineStates {
|
||||
idle = 'idle',
|
||||
readingFolders = 'readingFolders',
|
||||
settingProjectDirectoryPath = 'settingProjectDirectoryPath',
|
||||
openingProject = 'openingProject'
|
||||
openingProject = 'openingProject',
|
||||
}
|
||||
|
||||
const donePrefix = 'xstate.done.actor.'
|
||||
@ -41,5 +41,5 @@ export type SystemIOContext = {
|
||||
// has the application gone through the initialiation of systemIOMachine at least once.
|
||||
// this is required to prevent chokidar from spamming invalid events during initialization.
|
||||
hasListedProjects: boolean
|
||||
requestedProjectName: {name: string}
|
||||
requestedProjectName: { name: string }
|
||||
}
|
||||
|
Reference in New Issue
Block a user