Merge pull request #980 from ethereum/yann300-patch-27-1

fix switching workspaces
pull/953/head
yann300 4 years ago committed by GitHub
commit 57bced5051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      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', () => {
@ -217,6 +222,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 +234,6 @@ export const Workspace = (props: WorkspaceProps) => {
setState(prevState => {
return { ...prevState, currentWorkspace: name }
})
props.setWorkspace({ name, isLocalhost: name === LOCALHOST })
}
const remixdExplorer = {

Loading…
Cancel
Save