From 43c0eb9cb6c6a74ebbca22cb16ef8ea2963394e5 Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 15 Oct 2014 17:18:30 -0300 Subject: [PATCH] handle 0 wallets --- index.html | 2 +- js/controllers/home.js | 8 ++++---- js/models/Identity.js | 3 +-- js/services/controllerUtils.js | 7 +++++-- views/includes/sidebar.html | 26 ++++++++++++-------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/index.html b/index.html index c49932b8d..ba0becd4a 100644 --- a/index.html +++ b/index.html @@ -65,7 +65,7 @@ class="sidebar" ng-if="$root.iden"> -
+
diff --git a/js/controllers/home.js b/js/controllers/home.js index 0b606146e..fc11bd7d9 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -3,15 +3,15 @@ angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager) { controllerUtils.redirIfLogged(); - $scope.retreiving =true; + $scope.retreiving = true; copay.Identity.anyProfile({ pluginManager: pluginManager, }, function(any) { - $scope.retreiving =false; + $scope.retreiving = false; if (!any) $location.path('/createProfile'); }); - + $scope.openProfile = function(form) { if (form && form.$invalid) { @@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc if (err && !iden) { console.log('Error:' + err) controllerUtils.onErrorDigest( - $scope, (err.toString()||'').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error'); + $scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error'); } else { controllerUtils.bindProfile($scope, iden, firstWallet); } diff --git a/js/models/Identity.js b/js/models/Identity.js index 2a0472ab4..15e7953b7 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -190,9 +190,8 @@ Identity.open = function(email, password, opts, cb) { iden.profile = profile; var wids = _.pluck(iden.listWallets(), 'id'); - if (!wids || !wids.length) - return new Error('Could not open any wallet from profile'); + return cb(new Error('Could not open any wallet from profile'), iden); // Open All wallets from profile //This could be optional, or opts.onlyOpen = wid diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 6f173e71a..668fe2539 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -217,10 +217,13 @@ angular.module('copayApp.services') }; root.bindProfile = function($scope, iden, w) { - root.setupGlobalVariables(iden); root.rebindWallets($scope, iden); - root.setFocusedWallet(w); + if (w) { + root.setFocusedWallet(w); + } else { + $location.path('/manage'); + } }; diff --git a/views/includes/sidebar.html b/views/includes/sidebar.html index fccee319d..f1bc8b851 100644 --- a/views/includes/sidebar.html +++ b/views/includes/sidebar.html @@ -10,7 +10,6 @@ - +