From 19f6118f7fef94d3e77397bb8e466d8daef65abf Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 21 Oct 2014 10:54:19 -0300 Subject: [PATCH] Fixes if last focused wallet is undefined --- js/models/Profile.js | 10 +++++++++- views/includes/sidebar.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/models/Profile.js b/js/models/Profile.js index 5b5692aa6..c050cdedc 100644 --- a/js/models/Profile.js +++ b/js/models/Profile.js @@ -148,10 +148,18 @@ Profile.prototype.setLastFocusedTs = function(walletId, cb) { Profile.prototype.getLastFocusedWallet = function() { var self = this; + var last; var maxTs = _.max(_.pluck(self.walletInfos, 'lastFocusedTs')); - var last = _.findWhere(_.values(self.walletInfos), { + var wallets = _.values(self.walletInfos); + + last = _.findWhere(wallets, { lastFocusedTs: maxTs }); + + if (!last) { + last = _.last(wallets); + } + return last ? last.id : null; }; diff --git a/views/includes/sidebar.html b/views/includes/sidebar.html index f8187f2b3..bbdf65a7e 100644 --- a/views/includes/sidebar.html +++ b/views/includes/sidebar.html @@ -1,5 +1,5 @@
-
+
P