fix walletID list

This commit is contained in:
Matias Alejo Garcia 2014-04-17 12:58:54 -03:00
parent e28be27bf3
commit a51ed6c66d
3 changed files with 8 additions and 3 deletions

View File

@ -74,7 +74,7 @@
</div> </div>
</div> </div>
<hr> <hr>
<div ng-show="walletIds.length === 0"> <div ng-show="!walletIds.length">
<div class="row"> <div class="row">
<div class="large-6 columns"> <div class="large-6 columns">
<h3>Create a New Wallet</h3> <h3>Create a New Wallet</h3>

View File

@ -10,7 +10,8 @@ angular.module('copay.signin').controller('SigninController',
$scope.loading = false; $scope.loading = false;
$scope.walletIds = walletFactory.getWalletIds(); $scope.walletIds = walletFactory.getWalletIds();
$scope.selectedWalletId = $scope.walletIds?$scope.walletIds.shift():null;
$scope.selectedWalletId = $scope.walletIds.length ? $scope.walletIds[0]:null;
$scope.create = function() { $scope.create = function() {
$location.path('setup'); $location.path('setup');

View File

@ -54,13 +54,17 @@ Storage.prototype.remove = function(walletId, k) {
Storage.prototype.getWalletIds = function() { Storage.prototype.getWalletIds = function() {
var walletIds = []; var walletIds = [];
var uniq = {};
for (var i = 0; i < localStorage.length; i++) { for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i); var key = localStorage.key(i);
var split = key.split('::'); var split = key.split('::');
if (split.length == 2) { if (split.length == 2) {
var walletId = split[0]; var walletId = split[0];
walletIds.push(walletId); if (typeof uniq[walletId] === 'undefined' ) {
walletIds.push(walletId);
uniq[walletId] = 1;
}
} }
} }