Parcourir la source

Edit mode: fix bug when XDG_DATA_DIRS is empty

feature/remote-launch
William Petit il y a 3 ans
Parent
révision
b92934fedc
1 fichiers modifiés avec 11 ajouts et 3 suppressions
  1. 11
    3
      src/store/actions/edit.js

+ 11
- 3
src/store/actions/edit.js Voir le fichier

@@ -28,12 +28,20 @@ exports.loadDesktopApps = function() {
28 28
 
29 29
     logger.info('Loading desktop apps...');
30 30
 
31
-    var baseDirs = global.process.env.XDG_DATA_DIRS.split(':').map(function(baseDir){
31
+    dispatch({ type: LOAD_DESKTOP_APPS });
32
+
33
+    var xdgDataDirs = global.process.env.XDG_DATA_DIRS;
34
+
35
+    if( !xdgDataDirs ) {
36
+      logger.warn('The environment variable XDG_DATA_DIRS is empty. Can\'t find any application.');
37
+      dispatch({ type: LOAD_DESKTOP_APPS_SUCCESS,  desktopApps: [] });
38
+      return;
39
+    }
40
+
41
+    var baseDirs = xdgDataDirs.split(':').map(function(baseDir){
32 42
       return path.join(baseDir, 'applications');
33 43
     });
34 44
 
35
-    dispatch({ type: LOAD_DESKTOP_APPS });
36
-
37 45
     return Util.DesktopApps.loadAllDesktopFiles(baseDirs)
38 46
       .then(function(desktopApps) {
39 47
         logger.info('Desktop apps loaded.');

Chargement…
Annuler
Enregistrer