remove settimeout

pull/1/head
yann300 7 years ago
parent aa863b9de7
commit 9f3884dd3c
  1. 4
      src/app/compiler/compiler.js
  2. 2
      src/app/files/basicReadOnlyExplorer.js
  3. 64
      src/app/files/browser-files.js

@ -49,9 +49,7 @@ function Compiler (handleImportCall) {
self.lastCompilationResult = null self.lastCompilationResult = null
self.event.trigger('compilationFinished', [false, {'error': { formattedMessage: error, severity: 'error' }}, files]) self.event.trigger('compilationFinished', [false, {'error': { formattedMessage: error, severity: 'error' }}, files])
} else { } else {
setTimeout(function () { compileJSON(input, optimize ? 1 : 0)
compileJSON(input, optimize ? 1 : 0)
}, 0)
} }
}) })
} }

@ -108,7 +108,7 @@ class BasicReadOnlyExplorer {
'/content': self.get(path) '/content': self.get(path)
}) })
}) })
setTimeout(_ => callback(null, tree), 0) callback(null, tree)
} }
removePrefix (path) { removePrefix (path) {

@ -118,42 +118,40 @@ function Files (storage) {
this.resolveDirectory = function (path, callback) { this.resolveDirectory = function (path, callback) {
var self = this var self = this
// path = '' + (path || '') // path = '' + (path || '')
setTimeout(function () { function hashmapize (obj, path, val) {
function hashmapize (obj, path, val) { var nodes = path.split('/')
var nodes = path.split('/') var i = 0
var i = 0 for (; i < nodes.length - 1; i++) {
for (; i < nodes.length - 1; i++) { var node = nodes[i]
var node = nodes[i] if (obj[node] === undefined) {
if (obj[node] === undefined) { obj[node] = {}
obj[node] = {}
}
obj = obj[node]
} }
obj[nodes[i]] = val obj = obj[node]
} }
var filesList = {} obj[nodes[i]] = val
// add r/w filesList to the list }
storage.keys().forEach((path) => { var filesList = {}
// NOTE: as a temporary measure do not show the config file // add r/w filesList to the list
if (path !== '.remix.config') { storage.keys().forEach((path) => {
filesList[self.type + '/' + path] = false // NOTE: as a temporary measure do not show the config file
} if (path !== '.remix.config') {
}) filesList[self.type + '/' + path] = false
// add r/o files to the list }
Object.keys(readonly).forEach((path) => { })
filesList[self.type + '/' + path] = true // add r/o files to the list
}) Object.keys(readonly).forEach((path) => {
var tree = {} filesList[self.type + '/' + path] = true
// This does not include '.remix.config', because it is filtered })
// inside list(). var tree = {}
Object.keys(filesList).forEach(function (path) { // This does not include '.remix.config', because it is filtered
hashmapize(tree, path, { // inside list().
'/readonly': self.isReadOnly(path), Object.keys(filesList).forEach(function (path) {
'/content': self.get(path) hashmapize(tree, path, {
}) '/readonly': self.isReadOnly(path),
'/content': self.get(path)
}) })
callback(null, tree) })
}, 0) callback(null, tree)
} }
this.removePrefix = function (path) { this.removePrefix = function (path) {

Loading…
Cancel
Save