[gnome-books/wip/hadess/open-in-foliate: 1/2] document: Simplify the app checking loop



commit f09ba14215ef169895d5cd77b83969d1f7bdab88
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Aug 3 17:10:33 2019 +0200

    document: Simplify the app checking loop
    
    No need for a big conditional when we can continue the loop early.

 src/documents.js | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 0a0c6f7e..9cec975d 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -826,20 +826,20 @@ var LocalDocument = new Lang.Class({
 
             let apps = Gio.app_info_get_recommended_for_type (this.mimeType);
             for (let i = 0; i < apps.length; i++) {
-                if (apps[i].supports_uris ()) {
-                    // Never offer to open in an archive handler
-                    if (apps[i].get_id() == 'org.gnome.FileRoller.desktop')
-                        continue;
-                    if (defaultApp && apps[i].equal (defaultApp)) {
-                        // Found the recommended app that's also the default
-                        recommendedApp = apps[i];
-                        break;
-                    }
-                    // Set the first recommendedApp as the default if
-                    // they don't match
-                    if (!recommendedApp)
-                        recommendedApp = apps[i];
+                if (!apps[i].supports_uris ())
+                    continue;
+                // Never offer to open in an archive handler
+                if (apps[i].get_id() == 'org.gnome.FileRoller.desktop')
+                    continue;
+                if (defaultApp && apps[i].equal (defaultApp)) {
+                    // Found the recommended app that's also the default
+                    recommendedApp = apps[i];
+                    break;
                 }
+                // Set the first recommendedApp as the default if
+                // they don't match
+                if (!recommendedApp)
+                    recommendedApp = apps[i];
             }
 
             this.defaultApp = recommendedApp;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]