pull/1647/head
bunsenstraat 3 years ago
parent 4ab7ef8270
commit a584dd6961
  1. 61
      apps/remix-ide/src/app/files/fileManager.js
  2. 4
      apps/remix-ide/src/lib/gist-handler.js
  3. 6
      libs/remix-ui/workspace/src/lib/actions/index.ts
  4. 2
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -725,12 +725,12 @@ class FileManager extends Plugin {
}
}
syncEditor (path) {
async syncEditor (path) {
var currentFile = this._deps.config.get('currentFile')
if (path !== currentFile) return
var provider = this.fileProviderOf(currentFile)
if (provider) {
provider.get(currentFile, (error, content) => {
await provider.get(currentFile, (error, content) => {
if (error) console.log(error)
this.editor.setText(content)
})
@ -739,42 +739,37 @@ class FileManager extends Plugin {
}
}
setBatchFiles (filesSet, fileProvider, override, callback) {
async setBatchFiles (filesSet, fileProvider, override, callback) {
const self = this
if (!fileProvider) fileProvider = 'browser'
if (!fileProvider) fileProvider = 'workspace'
if (override === undefined) override = false
async.each(Object.keys(filesSet), async (file, callback) => {
for (const file of Object.keys(filesSet)) {
if (override) {
try {
await self._deps.filesProviders[fileProvider].set(file, filesSet[file].content)
} catch (e) {
return callback(e.message || e)
}
self.syncEditor(fileProvider + file)
return callback()
}
helper.createNonClashingName(file, self._deps.filesProviders[fileProvider],
async (error, name) => {
if (error) {
modalDialogCustom.alert('Unexpected error loading the file ' + error)
} else if (helper.checkSpecialChars(name)) {
modalDialogCustom.alert('Special characters are not allowed')
} else {
try {
console.log('set ', fileProvider, name, filesSet[file].content)
await self._deps.filesProviders[fileProvider].set(name, filesSet[file].content)
} catch (e) {
return callback(e.message || e)
}
self.syncEditor(fileProvider + name)
}
callback()
await self._deps.filesProviders[fileProvider].set(file, filesSet[file].content, (e) => {
if (e) callback(e.message || e)
})
}, (error) => {
if (callback) callback(error)
})
await self.syncEditor(fileProvider + file)
} else {
helper.createNonClashingName(file, self._deps.filesProviders[fileProvider],
async (error, name) => {
if (error) {
modalDialogCustom.alert('Unexpected error loading the file ' + error)
} else if (helper.checkSpecialChars(name)) {
modalDialogCustom.alert('Special characters are not allowed')
} else {
try {
console.log('set ', fileProvider, name, filesSet[file].content)
await self._deps.filesProviders[fileProvider].set(name, filesSet[file].content)
} catch (e) {
return callback(e.message || e)
}
await self.syncEditor(fileProvider + name)
}
callback()
})
}
}x
}
currentWorkspace () {

@ -58,8 +58,8 @@ function GistHandler (_window) {
obj['/' + 'gist-' + gistId + '/' + path] = data.files[element]
})
console.log('loading gist', obj)
fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
await fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
if (!errorLoadingFile) {
console.log('gist loaded')
const provider = fileManager.getProvider('workspace')

@ -255,10 +255,10 @@ export const handleExpandPath = (paths: string[]) => {
dispatch(setExpandPath(paths))
}
const packageGistFiles = (directory) => {
const packageGistFiles = async (directory) => {
const workspaceProvider = plugin.fileProviders.workspace
const isFile = await workspaceProvider.isFile(directory)
return new Promise((resolve, reject) => {
const workspaceProvider = plugin.fileProviders.workspace
const isFile = workspaceProvider.isFile(directory)
const ret = {}
if (isFile) {

@ -116,7 +116,7 @@ export const loadWorkspacePreset = async (template: 'gist-template' | 'code-temp
obj['/' + 'gist-' + gistId + '/' + path] = data.files[element]
})
plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
await plugin.fileManager.setBatchFiles(obj, 'workspace', true, (errorLoadingFile) => {
if (!errorLoadingFile) {
const provider = plugin.fileManager.getProvider('workspace')

Loading…
Cancel
Save