Skip to content
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

Merged
merged 4 commits into from
Oct 2, 2019
Merged

fixed editing gists from last session #2384

merged 4 commits into from
Oct 2, 2019

Conversation

LianaHus
Copy link
Collaborator

@LianaHus LianaHus commented Oct 1, 2019

@@ -441,35 +441,42 @@ fileExplorer.prototype.toGist = function (id) {
}
}

async function getOriginalFiles (id) {
Copy link
Collaborator

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) { ... }

if (id) {
const fileList = Object.keys(this.files.origGistFiles)
const updatedFileList = Object.keys(packaged)
let originalFileList = getOriginalFiles(id)
Copy link
Collaborator

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)
Copy link
Collaborator

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)

@LianaHus LianaHus merged commit 7365892 into master Oct 2, 2019
@LianaHus LianaHus deleted the kuku branch October 2, 2019 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FE:Edit Gist is not working when gist was added in previouse session
2 participants