[polari/wip/fmuellner/misc-cleanups: 28/33] accountsMonitor: Minor cleanup



commit 6754bd809cd21dbaa9d1c9cd59f5ce6445840c3d
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Aug 6 03:20:06 2016 +0200

    accountsMonitor: Minor cleanup
    
    Use arrow notation to make the shutdown handling code more concise.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769582

 src/accountsMonitor.js |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 247250a..b290b0c 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -79,20 +79,16 @@ const AccountsMonitor = new Lang.Class({
     },
 
     _onPrepareShutdown: function() {
-        for (let account of this._accounts.values()) {
-            let presence = Tp.ConnectionPresenceType.OFFLINE;
-            if (account.requested_presence_type == presence)
-                continue;
-
+        let presence = Tp.ConnectionPresenceType.OFFLINE;
+        this.accounts.filter(a => a.requested_presence != presence).forEach(a => {
             this._app.hold();
-            account.request_presence_async(presence, 'offline', '',
-                Lang.bind(this, function(account, result) {
-                    try {
-                        account.request_presence_finish(result);
-                    } catch(e) { }
-                    this._app.release();
-                }));
-        }
+            a.request_presence_async(presence, 'offline', '', (a, res) => {
+                try {
+                    a.request_presence_finish(result);
+                } catch(e) { }
+                this._app.release();
+            });
+        });
     },
 
     _shouldMonitorAccount: function(account) {


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