[polari] pasteManager: Rearrange code a bit



commit ff10289775e34de9e8145cb318f2954b1aa7e3b2
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 6 21:04:44 2019 +0000

    pasteManager: Rearrange code a bit
    
    _onFileQueryFinish currently has up to three different variables that
    are called "res" in overlapping scopes, which is a bit crazy.
    Reduce this by splitting the code slightly differently.
    
    https://gitlab.gnome.org/GNOME/polari/merge_requests/133

 src/pasteManager.js | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/pasteManager.js b/src/pasteManager.js
index 463877e..53d3401 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -38,18 +38,16 @@ var PasteManager = class {
             Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
             Gio.FileQueryInfoFlags.NONE,
             GLib.PRIORITY_DEFAULT, null, (file, res) => {
-                this._onFileQueryFinish(file, res, title, callback);
+                try {
+                    let fileInfo = file.query_info_finish(res);
+                    this._handleFilePaste(file, fileInfo, title, callback);
+                } catch (e) {
+                    callback(null);
+                }
             });
     }
 
-    _onFileQueryFinish(file, res, title, callback) {
-        let fileInfo = null;
-        try {
-            fileInfo = file.query_info_finish(res);
-        } catch (e) {
-            callback(null);
-        }
-
+    _handleFilePaste(file, fileInfo, title, callback) {
         let contentType = fileInfo.get_content_type();
         let targetType = _getTargetForContentType(contentType);
 


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