fix open file

pull/5370/head
bunsenstraat 11 months ago
parent 9a90456583
commit b824f27262
  1. 17
      libs/remix-ui/workspace/src/lib/actions/index.ts

@ -55,9 +55,16 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
const electrOnProvider = filePanelPlugin.fileProviders.electron const electrOnProvider = filePanelPlugin.fileProviders.electron
const params = queryParams.get() as UrlParametersType const params = queryParams.get() as UrlParametersType
let editorMounted = false let editorMounted = false
let filePathToOpen = null
let workspaces = [] let workspaces = []
plugin.on('editor', 'editorMounted', async () => { plugin.on('editor', 'editorMounted', async () => {
editorMounted = true editorMounted = true
if(filePathToOpen){
setTimeout(async () => {
await plugin.fileManager.openFile(filePathToOpen)
filePathToOpen = null
}, 1000)
}
}) })
if (!(Registry.getInstance().get('platform').api.isDesktop())) { if (!(Registry.getInstance().get('platform').api.isDesktop())) {
workspaces = await getWorkspaces() || [] workspaces = await getWorkspaces() || []
@ -73,12 +80,12 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
plugin.setWorkspace({ name: 'code-sample', isLocalhost: false }) plugin.setWorkspace({ name: 'code-sample', isLocalhost: false })
dispatch(setCurrentWorkspace({ name: 'code-sample', isGitRepo: false })) dispatch(setCurrentWorkspace({ name: 'code-sample', isGitRepo: false }))
const filePath = await loadWorkspacePreset('code-template') const filePath = await loadWorkspacePreset('code-template')
plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { plugin.on('filePanel', 'workspaceInitializationCompleted', async () => {
if (editorMounted){ if (editorMounted){
setTimeout(async () => { setTimeout(async () => {
await plugin.fileManager.openFile(filePath)}, 2000) await plugin.fileManager.openFile(filePath)}, 1000)
}else{ }else{
plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) filePathToOpen = filePath
} }
}) })
} else if (params.address) { } else if (params.address) {
@ -127,9 +134,9 @@ export const initWorkspace = (filePanelPlugin) => async (reducerDispatch: React.
plugin.on('filePanel', 'workspaceInitializationCompleted', async () => { plugin.on('filePanel', 'workspaceInitializationCompleted', async () => {
if (editorMounted){ if (editorMounted){
setTimeout(async () => { setTimeout(async () => {
await plugin.fileManager.openFile(filePath)}, 2000) await plugin.fileManager.openFile(filePath)}, 1000)
}else{ }else{
plugin.on('editor', 'editorMounted', async () => await plugin.fileManager.openFile(filePath)) filePathToOpen = filePath
} }
}) })
plugin.call('notification', 'toast', `Added ${count} verified contract${count === 1 ? '' : 's'} from ${foundOnNetworks.join(',')} network${foundOnNetworks.length === 1 ? '' : 's'} of Etherscan for contract address ${contractAddress} !!`) plugin.call('notification', 'toast', `Added ${count} verified contract${count === 1 ? '' : 's'} from ${foundOnNetworks.join(',')} network${foundOnNetworks.length === 1 ? '' : 's'} of Etherscan for contract address ${contractAddress} !!`)

Loading…
Cancel
Save