show error message after click

This commit is contained in:
Javier 2016-03-14 12:21:55 -03:00
commit 7540ee0a65
4 changed files with 45 additions and 33 deletions

View file

@ -58,13 +58,13 @@
<div ng-if="!gettingAddress"> <div ng-if="!gettingAddress">
<ul class="no-bullet"> <ul class="no-bullet">
<li class="line-b" ng-repeat="w in wallets"> <li class="line-b" ng-repeat="w in wallets">
<a ng-click="w.needsBackup || selectWallet(w.id, w.name)" class="db oh"> <a ng-click="selectWallet(w.id, w.name)" class="db oh">
<div class="avatar-wallet" <div class="avatar-wallet"
ng-style="{'background-color':w.color}"> ng-style="{'background-color':w.color}">
<i class="icon-wallet size-21"></i> <i class="icon-wallet size-21"></i>
</div> </div>
<div class="ellipsis name-wallet text-bold">{{w.name || w.id}} <div class="ellipsis name-wallet text-bold">{{w.name || w.id}}
<span class="has-error right text-light size-12" ng-show="w.needsBackup"> <span class="has-error right text-light size-12" ng-show="needsBackup[w.id]">
<i class="icon-close-circle size-14"></i> <i class="icon-close-circle size-14"></i>
<span class="vm" translate>Needs backup</span> <span class="vm" translate>Needs backup</span>
</span> </span>

View file

@ -128,7 +128,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.isPrivKeyEncrypted = fc.isPrivKeyEncrypted(); self.isPrivKeyEncrypted = fc.isPrivKeyEncrypted();
self.externalSource = fc.getPrivKeyExternalSourceName(); self.externalSource = fc.getPrivKeyExternalSourceName();
self.account = fc.credentials.account; self.account = fc.credentials.account;
self.needsBackup = profileService.isBackupNeeded(self.walletId);
if (self.externalSource == 'trezor') if (self.externalSource == 'trezor')
self.account++; self.account++;
@ -153,6 +152,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
} }
} }
profileService.isBackupNeeded(self.walletId, function(needsBackup) {
self.needsBackup = needsBackup;
self.openWallet(function() { self.openWallet(function() {
if (!self.isComplete) { if (!self.isComplete) {
$log.debug('Wallet not complete after update... redirecting'); $log.debug('Wallet not complete after update... redirecting');
@ -165,6 +166,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
} }
}); });
}); });
});
}; };
self.setCustomBWSFlag = function() { self.setCustomBWSFlag = function() {

View file

@ -246,11 +246,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}; };
$scope.selectWallet = function(walletId, walletName) { $scope.selectWallet = function(walletId, walletName) {
profileService.isBackupNeeded(walletId, function(needsBackup) {
$scope.needsBackup = {};
$scope.needsBackup[walletId] = needsBackup;
if (needsBackup) return;
$scope.gettingAddress = true; $scope.gettingAddress = true;
$scope.selectedWalletName = walletName; $scope.selectedWalletName = walletName;
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}); });
addressService.getAddress(walletId, false, function(err, addr) { addressService.getAddress(walletId, false, function(err, addr) {
$scope.gettingAddress = false; $scope.gettingAddress = false;
@ -262,6 +268,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$modalInstance.close(addr); $modalInstance.close(addr);
}); });
});
}; };
}; };

View file

@ -668,12 +668,16 @@ angular.module('copayApp.services')
}); });
}; };
root.isBackupNeeded = function(walletId) { root.isBackupNeeded = function(walletId, cb) {
var c = root.getClient(walletId); var c = root.getClient(walletId);
if (c.isPrivKeyExternal()) return false; if (c.isPrivKeyExternal()) return cb(false);
if (!c.credentials.mnemonic) return false; if (!c.credentials.mnemonic) return cb(false);
if (c.credentials.network == 'testnet') return false; if (c.credentials.network == 'testnet') return cb(false);
return true;
storageService.getBackupFlag(walletId, function(err, val) {
if (err || val) return cb(false);
return cb(true);
});
}; };
root.getWallets = function(network) { root.getWallets = function(network) {
@ -690,8 +694,7 @@ angular.module('copayApp.services')
id: c.walletId, id: c.walletId,
network: c.network, network: c.network,
color: config.colorFor[c.walletId] || '#4A90E2', color: config.colorFor[c.walletId] || '#4A90E2',
copayerId: c.copayerId, copayerId: c.copayerId
needsBackup: root.isBackupNeeded(c.walletId)
}; };
}); });
if (network) { if (network) {