Merge pull request #2211 from ethereum/gistListFix

Gist list fix
pull/1/head
Liana Husikyan 5 years ago committed by GitHub
commit 2c603bc08e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      src/app/files/file-explorer.js
  2. 5
      src/lib/gist-handler.js

@ -411,14 +411,34 @@ fileExplorer.prototype.toGist = function (id) {
token: tokenAccess
})
if (id) {
const fileList = Object.keys(this.files.origGistFiles)
const updatedFileList = Object.keys(packaged)
// Telling the GIST API to remove files
const allItems = fileList
.filter(fileName => updatedFileList.indexOf(fileName) === -1)
.reduce((acc, deleteFileName) => ({
...acc,
[deleteFileName]: null
}), this.files.origGistFiles)
// adding new files
updatedFileList.forEach((file) => {
allItems[file] = packaged[file]
})
tooltip('Saving gist (' + id + ') ...')
gists.edit({
description: description,
public: true,
files: packaged,
files: allItems,
id: id
}, (error, result) => {
proccedResult(error, result)
if (!error) {
for (const key in allItems) {
if (allItems[key] === null) delete allItems[key]
}
this.files.origGistFiles = allItems
}
})
} else {
tooltip('Creating a new gist ...')
@ -491,7 +511,7 @@ fileExplorer.prototype.copyFiles = function () {
// ------------------ gist publish --------------
fileExplorer.prototype.updateGist = function () {
var gistId = this.files.id
const gistId = this.files.id
if (!gistId) {
tooltip('no gist content is currently loaded.')
} else {

@ -54,7 +54,10 @@ function GistHandler (_window) {
return
}
fileManager.setBatchFiles(data.files, 'gist', (errorLoadingFile) => {
if (!errorLoadingFile) gistProvider.id = gistId
if (!errorLoadingFile) {
gistProvider.id = gistId
gistProvider.origGistFiles = data.files
}
})
})
})

Loading…
Cancel
Save