fix switching workspace if disconnect

pull/980/head
yann300 4 years ago
parent b67fd2243d
commit 24af3f5e8e
  1. 7
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

@ -81,6 +81,12 @@ export const Workspace = (props: WorkspaceProps) => {
getWorkspaces() getWorkspaces()
}, [props.workspaces]) }, [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(() => { useEffect(() => {
props.localhost.event.register('connected', () => { props.localhost.event.register('connected', () => {
remixdExplorer.show() remixdExplorer.show()
@ -88,7 +94,6 @@ export const Workspace = (props: WorkspaceProps) => {
props.localhost.event.register('disconnected', () => { props.localhost.event.register('disconnected', () => {
remixdExplorer.hide() remixdExplorer.hide()
setWorkspace(props.workspaces.length > 0 ? props.workspaces[0] : NO_WORKSPACE)
}) })
props.localhost.event.register('loading', () => { props.localhost.event.register('loading', () => {

Loading…
Cancel
Save