Make projects watching code not run in web
This commit is contained in:
		| @ -22,9 +22,10 @@ import { | ||||
| import { useSettingsAuthContext } from 'hooks/useSettingsAuthContext' | ||||
| import useStateMachineCommands from 'hooks/useStateMachineCommands' | ||||
| import { projectsCommandBarConfig } from 'lib/commandBarConfigs/projectsCommandConfig' | ||||
| import { isDesktop } from 'lib/isDesktop' | ||||
|  | ||||
| type MachineContext<T extends AnyStateMachine> = { | ||||
|   state: StateFrom<T> | ||||
|   state?: StateFrom<T> | ||||
|   send: Prop<Actor<T>, 'send'> | ||||
| } | ||||
|  | ||||
| @ -32,10 +33,42 @@ export const ProjectsMachineContext = createContext( | ||||
|   {} as MachineContext<typeof projectsMachine> | ||||
| ) | ||||
|  | ||||
| /** | ||||
|  * Watches the project directory and provides project management-related commands, | ||||
|  * like "Create project", "Open project", "Delete project", etc. | ||||
|  * | ||||
|  * If in the future we implement full-fledge project management in the web version, | ||||
|  * we can unify these components but for now, we need this to be only for the desktop version. | ||||
|  */ | ||||
| export const ProjectsContextProvider = ({ | ||||
|   children, | ||||
| }: { | ||||
|   children: React.ReactNode | ||||
| }) => { | ||||
|   return isDesktop() ? ( | ||||
|     <ProjectsContextDesktop>{children}</ProjectsContextDesktop> | ||||
|   ) : ( | ||||
|     <ProjectsContextWeb>{children}</ProjectsContextWeb> | ||||
|   ) | ||||
| } | ||||
|  | ||||
| const ProjectsContextWeb = ({ children }: { children: React.ReactNode }) => { | ||||
|   return ( | ||||
|     <ProjectsMachineContext.Provider | ||||
|       value={{ | ||||
|         state: undefined, | ||||
|         send: () => {}, | ||||
|       }} | ||||
|     > | ||||
|       {children} | ||||
|     </ProjectsMachineContext.Provider> | ||||
|   ) | ||||
| } | ||||
|  | ||||
| const ProjectsContextDesktop = ({ | ||||
|   children, | ||||
| }: { | ||||
|   children: React.ReactNode | ||||
| }) => { | ||||
|   const navigate = useNavigate() | ||||
|   const location = useLocation() | ||||
|  | ||||
| @ -54,10 +54,11 @@ export const projectsCommandBarConfig: StateMachineCommandSetConfig< | ||||
|     icon: 'close', | ||||
|     description: 'Delete a project', | ||||
|     needsReview: true, | ||||
|     reviewMessage: ({ argumentsToSubmit }) => CommandBarOverwriteWarning({ | ||||
|       heading: 'Are you sure you want to delete?', | ||||
|       message: `This will permanently delete the project "${argumentsToSubmit.name}" and all its contents.`, | ||||
|     }), | ||||
|     reviewMessage: ({ argumentsToSubmit }) => | ||||
|       CommandBarOverwriteWarning({ | ||||
|         heading: 'Are you sure you want to delete?', | ||||
|         message: `This will permanently delete the project "${argumentsToSubmit.name}" and all its contents.`, | ||||
|       }), | ||||
|     args: { | ||||
|       name: { | ||||
|         inputType: 'options', | ||||
|  | ||||
| @ -206,7 +206,7 @@ export const projectsMachine = setup({ | ||||
|         onDone: [ | ||||
|           { | ||||
|             target: '#Home machine.Reading projects', | ||||
|             actions: ['toastSuccess', "navigateToProjectIfNeeded"], | ||||
|             actions: ['toastSuccess', 'navigateToProjectIfNeeded'], | ||||
|           }, | ||||
|         ], | ||||
|         onError: [ | ||||
|  | ||||
		Reference in New Issue
	
	Block a user