removed the external promise dependency as it was flacky + it was simpler to remove than to investigate with the existing native Promises now...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-04-15 02:09:02 +03:00
parent ed9018b641
commit 69f60c1a7e
4 changed files with 45 additions and 21 deletions

View File

@ -21,9 +21,9 @@ var base = require('features/base')
var AppControlActions = actions.Actions({
config: {
'application-window': null,
'window-title': 'ImageGrid.Viewer (${VERSION}): ${FILENAME}',
'window-delay-initial-display': 200,
},
// XXX revise these...
@ -86,20 +86,23 @@ var AppControlActions = actions.Actions({
this.centerViewer()
}
win.show()
// XXX check if we are full screen...
if(cfg != null && cfg.fullscreen && !win.isFullscreen){
this.toggleFullScreen('on')
}
/* XXX still buggy....
// restore interface scale...
this.toggleInterfaceScale(
this.config['ui-scale-mode']
|| this.toggleInterfaceScale('??')[0])
*/
// NOTE: we delay this to enable the browser time to render
// things before we show them to the user...
setTimeout(function(){
win.show()
// XXX check if we are full screen...
if(cfg != null && cfg.fullscreen && !win.isFullscreen){
this.toggleFullScreen('on')
}
}, this.config['window-delay-initial-display'] || 0)
}],
toggleFullScreen: ['Interface/Toggle full screen mode',

View File

@ -9,7 +9,6 @@ var events = require('events')
var fse = require('fs-extra')
var glob = require('glob')
var Promise = require('promise')
// XXX seems that we need different buids of this for use with node and nw...
// XXX BUG: nw-gyp does not support msvs2015...
@ -95,10 +94,20 @@ function listJSON(path, pattern){
return gGlob(path +'/'+ pattern +'.json')
}
// XXX move to someplace generic...
var denodeify = function(func){
return function(){
return new Promise(function(resolve, reject){
func.apply(null, args2array(arguments).concat([function(err, res){
err ? reject(err) : resolve(res)
}]))
})
}
}
var loadFile = Promise.denodeify(fse.readFile)
var writeFile = Promise.denodeify(fse.writeFile)
var ensureDir = Promise.denodeify(fse.ensureDir)
var loadFile = denodeify(fse.readFile)
var writeFile = denodeify(fse.writeFile)
var ensureDir = denodeify(fse.ensureDir)
// XXX handle errors...

View File

@ -8,7 +8,6 @@ if(typeof(process) != 'undefined'){
var os = require('os')
var fs = require('fs')
var path = require('path')
var promise = require('promise')
var glob = require('glob')
var guaranteeEvents = require('guarantee-events')
}
@ -19,7 +18,7 @@ define(function(require){ var module = {}
// XXX HACK...
// ...for some reason this gets loaded in browser...
if(typeof(process) == 'undefined'){
return module
return modul
}
@ -46,7 +45,7 @@ function(path, make){
var fullpath = path.indexOf('*') >= 0
path = path.indexOf('*') < 0 ? path + '/*' : path
return new promise(function(resolve, reject){
return new Promise(function(resolve, reject){
// XXX do we need this???
/*guaranteeEvents([
'match',
@ -84,11 +83,17 @@ function(path, make){
// XXX expose these as config...
var fullpath = false
var stat = promise.denodeify(fs.stat)
var stat = function(path){
return new Promise(function(resolve, reject){
fs.stat.call(fs, path, function(err, res){
err ? reject(err) : resolve(res)
})
})
}
// get the drive list on windows...
if(os.type() == 'Windows_NT' && path == '/'){
return new promise(function(resolve, reject){
return new Promise(function(resolve, reject){
// NOTE: this is a bit brain-dead but it gets the job done
// and faster than fancy modules like drivelist...
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
@ -110,7 +115,7 @@ function(path, make){
// list dirs...
} else {
return new promise(function(resolve, reject){
return new Promise(function(resolve, reject){
// XXX should this be a promise???
fs.readdir(path, function(err, files){
// XXX
@ -128,6 +133,14 @@ function(path, make){
: file, null, true)
})
.then(function(res){
// can't read stat... (XXX ???)
if(res == null){
make(fullpath
? path +'/'+ file
: file, null, true)
return
}
var dir = res.isDirectory()
var elem = res && make(fullpath
? path +'/'+ file

View File

@ -17,7 +17,6 @@
"page-cache": true
},
"dependencies": {
"promise": "*",
"commander": "^2.9.0",
"exiftool": "0.0.3",
"flickrapi": "^0.3.28",