[polari/gnome-3-20] networksManager: Refactor code a bit
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/gnome-3-20] networksManager: Refactor code a bit
- Date: Thu, 4 Aug 2016 21:47:59 +0000 (UTC)
commit 578627901a5ca0bd5f6c84d15cb84b5a641ec74b
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Jun 3 17:07:09 2016 +0200
networksManager: Refactor code a bit
We are about to load the initial networks list immediately, but may
want to asynchronously fetch an up-to-date list from the network
in the future. So split out a parseNetworks() function that can be
used in both code paths.
https://bugzilla.gnome.org/show_bug.cgi?id=766935
src/networksManager.js | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/networksManager.js b/src/networksManager.js
index c4499ee..2ac7584 100644
--- a/src/networksManager.js
+++ b/src/networksManager.js
@@ -32,21 +32,26 @@ const NetworksManager = new Lang.Class({
log('Failed to load network list: ' + e.message);
return;
}
+ if (this._parseNetworks(data))
+ this.emit('changed');
+ },
+ _parseNetworks: function(data) {
let networks;
try {
networks = JSON.parse(data);
} catch(e) {
log('Failed to parse network list: ' + e.message);
- return;
+ return false;
}
+ this._networksById.clear();
this._networks = networks;
this._networks.forEach(Lang.bind(this,
function(network) {
this._networksById.set(network.id, network);
}));
- this.emit('changed');
+ return true;
},
_lookupNetwork: function(id) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]