From 4567778e6009847548800339d5c810f34c23b9e3 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 29 Mar 2023 12:10:47 +0200 Subject: [PATCH] fixes for workspace with conflicting localstorage --- apps/remix-ide/src/app/panels/file-panel.js | 1 + libs/remix-ui/workspace/src/lib/actions/index.ts | 3 ++- .../workspace/src/lib/remix-ui-workspace.tsx | 12 +++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index d088ffa367..fce1966257 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -95,6 +95,7 @@ module.exports = class Filepanel extends ViewPlugin { } getAvailableWorkspaceName (name) { + if(!this.workspaces) return null let index = 1 let workspace = this.workspaces.find(workspace => workspace.name === name + ' - ' + index) while (workspace) { diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 424daf41d9..662ad81375 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -53,7 +53,6 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. const params = queryParams.get() as UrlParametersType const workspaces = await getWorkspaces() || [] dispatch(setWorkspaces(workspaces)) - // console.log('workspaces: ', workspaces) if (params.gist) { await createWorkspaceTemplate('gist-sample', 'gist-template') plugin.setWorkspace({ name: 'gist-sample', isLocalhost: false }) @@ -124,6 +123,8 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React. workspaceProvider.setWorkspace(name) plugin.setWorkspace({ name: name, isLocalhost: false }) dispatch(setCurrentWorkspace({ name: name, isGitRepo: false })) + }else{ + await basicWorkspaceInit(workspaces, workspaceProvider) } } else { await basicWorkspaceInit(workspaces, workspaceProvider) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 9fe482a0d7..860f15ad2a 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -47,9 +47,15 @@ export function Workspace () { useEffect(() => { if (global.fs.mode === 'browser') { - if (global.fs.browser.currentWorkspace) setCurrentWorkspace(global.fs.browser.currentWorkspace) - else setCurrentWorkspace(NO_WORKSPACE) - global.dispatchFetchWorkspaceDirectory(ROOT_PATH) + if (global.fs.browser.currentWorkspace) { + setCurrentWorkspace(global.fs.browser.currentWorkspace) + global.dispatchFetchWorkspaceDirectory(ROOT_PATH) + } + else + { + setCurrentWorkspace(NO_WORKSPACE) + } + } else if (global.fs.mode === 'localhost') { global.dispatchFetchWorkspaceDirectory(ROOT_PATH) setCurrentWorkspace(LOCALHOST)