[gnome-shell] network: Deduplicate some similar code



commit 37dce7d4c37c490200ba168ca45bb4f9b4ed35dd
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Apr 25 16:24:14 2013 -0400

    network: Deduplicate some similar code
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698918

 js/ui/status/network.js |   28 +++++++++-------------------
 1 files changed, 9 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 3f086b3..cb52458 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -2092,25 +2092,7 @@ const NMApplet = new Lang.Class({
         return false;
     },
 
-    _readConnections: function() {
-        let connections = this._settings.list_connections();
-        for (let i = 0; i < connections.length; i++) {
-            let connection = connections[i];
-            if (this._ignoreConnection(connection))
-                continue;
-            if (connection._updatedId) {
-                // connection was already seen (for example because NetworkManager was restarted)
-                continue;
-            }
-            connection._removedId = connection.connect('removed', Lang.bind(this, this._connectionRemoved));
-            connection._updatedId = connection.connect('updated', Lang.bind(this, this._updateConnection));
-
-            this._updateConnection(connection);
-            this._connections.push(connection);
-        }
-    },
-
-    _newConnection: function(settings, connection) {
+    _addConnection: function(connection) {
         if (this._ignoreConnection(connection))
             return;
         if (connection._updatedId) {
@@ -2123,7 +2105,15 @@ const NMApplet = new Lang.Class({
 
         this._updateConnection(connection);
         this._connections.push(connection);
+    },
 
+    _readConnections: function() {
+        let connections = this._settings.list_connections();
+        connections.forEach(Lang.bind(this, this._addConnection));
+    },
+
+    _newConnection: function(settings, connection) {
+        this._addConnection(connection);
         this._updateIcon();
     },
 


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