+
-
-
+
+
);
diff --git a/js/components/edit/profile-tree.js b/js/components/edit/profile-tree.js
index 98f867e..b785acf 100644
--- a/js/components/edit/profile-tree.js
+++ b/js/components/edit/profile-tree.js
@@ -55,6 +55,7 @@ var ProfileTree = React.createClass({
return (
+
{this.renderTreeNode(this.props.profile)}
);
diff --git a/js/util/desktop-apps.js b/js/util/desktop-apps.js
index 1b0f0f6..fbb03fe 100644
--- a/js/util/desktop-apps.js
+++ b/js/util/desktop-apps.js
@@ -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] };
@@ -47,12 +46,10 @@ exports.findAllDesktopFiles = function(baseDirs) {
if(!Array.isArray(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) {
diff --git a/js/util/promises.js b/js/util/promises.js
new file mode 100644
index 0000000..f7ddfda
--- /dev/null
+++ b/js/util/promises.js
@@ -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);
+ };
+ }
+
+};