Chargement séquentiel des applications/icones
This commit is contained in:
parent
7db3d9eb69
commit
747f3519e0
|
@ -21,11 +21,9 @@ var EditView = React.createClass({
|
|||
|
||||
return (
|
||||
<div className="edit">
|
||||
<div className="menu-bar">
|
||||
<ProfileMenu />
|
||||
</div>
|
||||
<div className="workspace">
|
||||
<div className="left-menu">
|
||||
<ProfileMenu />
|
||||
<IconThemeSelector onThemeSelected={this.handleThemeSelect} />
|
||||
<DesktopAppList
|
||||
theme={this.props.theme}
|
||||
|
|
|
@ -10,8 +10,8 @@ var ProfileMenu = React.createClass({
|
|||
|
||||
return (
|
||||
<div className="profile-menu">
|
||||
<button className="btn btn-default" onClick={this.handleOpenClick}>Ouvrir</button>
|
||||
<button className="btn btn-primary" onClick={this.handleSaveClick}>Enregistrer</button>
|
||||
<button className="btn btn-default btn-sm" onClick={this.handleOpenClick}>Ouvrir</button>
|
||||
<button className="btn btn-primary btn-sm" onClick={this.handleSaveClick}>Enregistrer</button>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ var ProfileTree = React.createClass({
|
|||
|
||||
return (
|
||||
<div className="profile-tree">
|
||||
<button className="btn btn-primary pull-right btn-sm" onClick={this.handleAddNewNode}>Ajouter un noeud</button>
|
||||
{this.renderTreeNode(this.props.profile)}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@ var path = require('path');
|
|||
var System = require('./system');
|
||||
var debug = require('./debug')('desktop-apps');
|
||||
var Cache = require('./cache');
|
||||
var promises = require('./promises');
|
||||
|
||||
// Constants
|
||||
var ICON_REALPATH_REGEX = /\..+$/;
|
||||
|
@ -19,11 +20,9 @@ exports.loadAllDesktopFiles = function(rootDirs) {
|
|||
return exports.findAllDesktopFiles(rootDirs)
|
||||
.then(function(filePaths) {
|
||||
|
||||
var promises = filePaths.map(function(path) {
|
||||
return exports.loadDesktopFile(path);
|
||||
});
|
||||
|
||||
return Promise.all(promises)
|
||||
return promises.seq(filePaths, function(path) {
|
||||
return exports.loadDesktopFile(path);
|
||||
})
|
||||
.then(function(contents) {
|
||||
return contents.map(function(content, i) {
|
||||
return { content: content, path: filePaths[i] };
|
||||
|
@ -48,11 +47,9 @@ exports.findAllDesktopFiles = function(baseDirs) {
|
|||
baseDirs = [baseDirs];
|
||||
}
|
||||
|
||||
var promises = baseDirs.map(function(baseDir) {
|
||||
return System.findFiles('**/*.desktop', {cwd: baseDir, realpath: true});
|
||||
});
|
||||
|
||||
return Promise.all(promises)
|
||||
return promises.seq(baseDirs, function(baseDir) {
|
||||
return System.findFiles('**/*.desktop', {cwd: baseDir, realpath: true});
|
||||
})
|
||||
.then(function(apps) {
|
||||
return uniq(flatten(apps));
|
||||
})
|
||||
|
@ -104,10 +101,9 @@ exports.findIcon = function(iconName, themeName, size, themeIgnore) {
|
|||
return exports.findIconThemes()
|
||||
.then(function(themes) {
|
||||
themeIgnore = themeIgnore || [];
|
||||
var promises = themes.map(function(theme) {
|
||||
return exports.findIcon(iconName, theme, size, themeIgnore);
|
||||
});
|
||||
return Promise.all(promises)
|
||||
return promises.seq(themes, function(theme) {
|
||||
return exports.findIcon(iconName, theme, size, themeIgnore);
|
||||
})
|
||||
.then(exports._selectBestIcon)
|
||||
;
|
||||
})
|
||||
|
@ -160,11 +156,9 @@ exports.findParentsThemeIcon = function(iconName, themeName, size, themeIgnore)
|
|||
|
||||
debug('Found parents %j', parents);
|
||||
|
||||
var promises = parents.map(function(themeName) {
|
||||
return exports.findIcon(iconName, themeName, size, themeIgnore);
|
||||
});
|
||||
|
||||
return Promise.all(promises)
|
||||
return promises.seq(parents, function(themeName) {
|
||||
return exports.findIcon(iconName, themeName, size, themeIgnore);
|
||||
})
|
||||
.then(exports._selectBestIcon)
|
||||
;
|
||||
|
||||
|
@ -278,7 +272,6 @@ exports._selectBestIcon = function(iconPaths) {
|
|||
return iconSelection.scalable || iconSelection.bitmap;
|
||||
};
|
||||
|
||||
|
||||
// Array helpers
|
||||
|
||||
function clean(arr) {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
|
||||
exports.seq = function(items, generator) {
|
||||
|
||||
var results = [];
|
||||
var p = Promise.resolve();
|
||||
|
||||
for(var i = 0, len = items.length; i < len; ++i) {
|
||||
p = p.then(generateNextHandler(items[i], i === 0));
|
||||
}
|
||||
|
||||
return p.then(function(lastResult) {
|
||||
results.push(lastResult);
|
||||
return results;
|
||||
});
|
||||
|
||||
// Internal helper
|
||||
function generateNextHandler(item, ignoreResult) {
|
||||
return function(prevResult) {
|
||||
if(!ignoreResult) results.push(prevResult);
|
||||
return generator(item, prevResult);
|
||||
};
|
||||
}
|
||||
|
||||
};
|
Loading…
Reference in New Issue