[gnome-weather] app/world.js: Check if model is already populated at init
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-weather] app/world.js: Check if model is already populated at init
- Date: Tue, 3 Mar 2015 03:31:23 +0000 (UTC)
commit 27f7a1078499a8db953286dc667a09f97e01e7ce
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Sun Mar 1 13:53:45 2015 +0100
app/world.js: Check if model is already populated at init
If this is not the first window, the model might already been
loaded. Make sure we add all locations currently in the model.
https://bugzilla.gnome.org/show_bug.cgi?id=740414
src/app/world.js | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/app/world.js b/src/app/world.js
index 99d0fab..5d92895 100644
--- a/src/app/world.js
+++ b/src/app/world.js
@@ -119,7 +119,13 @@ const WorldContentView = new Lang.Class({
this.model.connect('location-added', Lang.bind(this, this._onLocationAdded));
this.model.connect('location-removed', Lang.bind(this, this._onLocationRemoved));
- this.model.load();
+ if (this.model.length > 0) {
+ this.model.getAll().forEach(Lang.bind(this, function(info) {
+ this._onLocationAdded(this.model, info, info._isCurrentLocation);
+ }));
+ } else {
+ this.model.load();
+ }
},
_filterListbox: function(row, model) {
@@ -184,7 +190,9 @@ const WorldContentView = new Lang.Class({
if (isCurrentLocation) {
if (model.addedCurrentLocation) {
- this._listbox.get_row_at_index(0).destroy();
+ let row0 = this._listbox.get_row_at_index(0);
+ if (row0)
+ row0.destroy();
}
this._listbox.insert(row, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]