fixing save workspace

fixinganerror
lianahus 1 year ago
parent 7611385fac
commit 5deb63c20a
  1. 10
      apps/remix-ide/src/app/panels/file-panel.js
  2. 6
      libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx

@ -163,13 +163,13 @@ module.exports = class Filepanel extends ViewPlugin {
})
}
saveRecent (workspace) {
saveRecent (workspaceName) {
if (!localStorage.getItem('recentWorkspaces')) {
localStorage.setItem('recentWorkspaces', JSON.stringify({first: workspace, second:'', third:''}))
localStorage.setItem('recentWorkspaces', JSON.stringify({first: workspaceName, second:'', third:''}))
} else {
const recents = JSON.parse(localStorage.getItem('recentWorkspaces'))
if (recents.first !== workspace.name && recents.second !== workspace.name && recents.third !== workspace.name) {
let newResents = JSON.stringify({first: workspace.name, second: recents.first, third: recents.second})
if (recents.first !== workspaceName && recents.second !== workspaceName && recents.third !== workspaceName) {
let newResents = JSON.stringify({first: workspaceName, second: recents.first, third: recents.second})
localStorage.setItem('recentWorkspaces', newResents)
}
}
@ -183,7 +183,7 @@ module.exports = class Filepanel extends ViewPlugin {
localStorage.setItem('currentWorkspace', workspace.name)
}
if (this.currentWorkspaceMetadata.name !== current) {
this.saveRecent(workspace)
this.saveRecent(workspace.name)
}
this.emit('setWorkspace', workspace)
}

@ -125,10 +125,14 @@ function HomeTabFile({plugin}: HomeTabFileProps) {
const content = `// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract helloWorld {
function print() public pure returns (string memory) {
return "Hello World!";
}
}
`
const {newContent, 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)
}
const uploadFile = async (target) => {

Loading…
Cancel
Save