From b67fd2243d88055b19a51a5dc3b0be0e11ae9d8a Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 16 Mar 2021 12:01:00 +0100 Subject: [PATCH 1/2] fix switching workspaces --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cf1aab7d4d..81d5c59f1a 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -217,6 +217,7 @@ export const Workspace = (props: WorkspaceProps) => { } const setWorkspace = async (name) => { + props.setWorkspace({ name, isLocalhost: name === LOCALHOST }) if (name === LOCALHOST) { props.workspace.clearWorkspace() } else if (name === NO_WORKSPACE) { @@ -228,7 +229,6 @@ export const Workspace = (props: WorkspaceProps) => { setState(prevState => { return { ...prevState, currentWorkspace: name } }) - props.setWorkspace({ name, isLocalhost: name === LOCALHOST }) } const remixdExplorer = { From 24af3f5e8eddbb0ea88dc86f823513f3319d0a73 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 16 Mar 2021 16:00:52 +0100 Subject: [PATCH 2/2] fix switching workspace if disconnect --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 81d5c59f1a..91038fa139 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -81,6 +81,12 @@ export const Workspace = (props: WorkspaceProps) => { getWorkspaces() }, [props.workspaces]) + const localhostDisconnect = () => { + if (state.currentWorkspace === LOCALHOST) setWorkspace(props.workspaces.length > 0 ? props.workspaces[0] : NO_WORKSPACE) + } + props.localhost.event.unregister('disconnected', localhostDisconnect) + props.localhost.event.register('disconnected', localhostDisconnect) + useEffect(() => { props.localhost.event.register('connected', () => { remixdExplorer.show() @@ -88,7 +94,6 @@ export const Workspace = (props: WorkspaceProps) => { props.localhost.event.register('disconnected', () => { remixdExplorer.hide() - setWorkspace(props.workspaces.length > 0 ? props.workspaces[0] : NO_WORKSPACE) }) props.localhost.event.register('loading', () => {