fix open default file

pull/3654/head
yann300 1 year ago
parent 24e31009bf
commit 1c198c5a77
  1. 7
      libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx

@ -134,8 +134,10 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
const wName = 'Playground' const wName = 'Playground'
const workspaces = await plugin.call('filePanel', 'getWorkspaces') const workspaces = await plugin.call('filePanel', 'getWorkspaces')
let createFile = true
if (!workspaces.find((workspace) => workspace.name === wName)) { if (!workspaces.find((workspace) => workspace.name === wName)) {
await plugin.call('filePanel', 'createWorkspace', wName, 'playground') await plugin.call('filePanel', 'createWorkspace', wName, 'playground')
createFile = false
} }
await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false })
await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // calling once is not working. await plugin.call('filePanel', 'switchToWorkspace', { name: wName, isLocalHost: false }) // calling once is not working.
@ -148,8 +150,13 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
} }
} }
` `
if (createFile) {
const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content) const { newPath } = await plugin.call('fileManager', 'writeFileNoRewrite', '/contracts/helloWorld.sol', content)
await plugin.call('fileManager', 'open', newPath) await plugin.call('fileManager', 'open', newPath)
} else {
await plugin.call('fileManager', 'open', '/contracts/helloWorld.sol')
}
} }
const uploadFile = async (target) => { const uploadFile = async (target) => {

Loading…
Cancel
Save