-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed editing gists from last session #2384
Conversation
@@ -441,35 +441,42 @@ fileExplorer.prototype.toGist = function (id) { | |||
} | |||
} | |||
|
|||
async function getOriginalFiles (id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment with jsdoc synthax so we can understand what this function is doing :
/**
* This function is awesome
* @params id The if of....
*/
async function getOriginalFiles (id) { ... }
src/app/files/file-explorer.js
Outdated
if (id) { | ||
const fileList = Object.keys(this.files.origGistFiles) | ||
const updatedFileList = Object.keys(packaged) | ||
let originalFileList = getOriginalFiles(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're ne reassigning this value later. You can use const
.filter(fileName => updatedFileList.indexOf(fileName) === -1) | ||
.reduce((acc, deleteFileName) => ({ | ||
...acc, | ||
[deleteFileName]: null | ||
}), this.files.origGistFiles) | ||
}), originalFileList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read an article that says that it's actually not a good idea to use spead operator (...) inside a reduce as it's increase the complexity of the function from On to On² (spread operator iterate on each element). Here, the amount of elements is small so it's ok.
You could do that to improve it :
reduce((acc, deleteFileName) => {
delete acc[deleteFileName]
return acc
}, originalFileList)
fixes https://github.com/ethereum/remix-ide/issues/2382