Merge pull request #3993 from JDonadio/fix/needs-backup

Display backup message in addressbook
This commit is contained in:
Gustavo Maximiliano Cortez 2016-03-28 16:30:02 -03:00
commit 76ce26d898
5 changed files with 69 additions and 70 deletions

View File

@ -63,7 +63,12 @@
ng-style="{'background-color':w.color}">
<i class="icon-wallet size-21"></i>
</div>
<div class="ellipsis name-wallet text-bold">{{w.name || w.id}}</div>
<div class="ellipsis name-wallet text-bold">{{w.name || w.id}}
<span class="has-error right text-light size-12" ng-show="needsBackup[w.id]">
<i class="icon-close-circle size-14"></i>
<span class="vm" translate>Needs backup</span>
</span>
</div>
<div class="size-12">{{w.m}} of {{w.n}}
<span ng-show="w.network=='testnet'">[Testnet]</span>
</div>

View File

@ -420,11 +420,7 @@
<i class="icon-close-circle size-14"></i>
<span class="vm" translate>Not valid</span>
</span>
<span class="has-error right size-12" ng-show="home.destinationWalletNeedsBackup">
<i class="icon-close-circle size-14"></i>
<span class="vm" translate>Destination wallet needs backup</span>
</span>
<small class="right text-primary" ng-show="!sendForm.address.$invalid && !home.destinationWalletNeedsBackup">
<small class="right text-primary" ng-show="!sendForm.address.$invalid">
<i class="icon-checkmark-circle size-14"></i>
</small>
</span>
@ -508,7 +504,7 @@
<a fast-click callback-fn="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
</div>
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || home.destinationWalletNeedsBackup"
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline"
ng-style="{'background-color':index.backgroundColor}" fast-click callback-fn="home.submitForm()" translate>
Send
</button>

View File

@ -603,10 +603,6 @@ ul.manage li {
color: #fff;
}
.name-wallet i {
color: #B6E9DF;
}
.locked {
font-size: 11px;
color: #7A8C9E;

View File

@ -130,7 +130,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var confirm_msg = gettextCatalog.getString('Confirm');
this.openDestinationAddressModal = function(wallets, address) {
self.destinationWalletNeedsBackup = null;
$rootScope.modalOpened = true;
var fc = profileService.focusedClient;
self.lockAddress = false;
@ -247,11 +246,17 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
$scope.selectWallet = function(walletId, walletName) {
profileService.isBackupNeeded(walletId, function(needsBackup) {
$scope.needsBackup = {};
$scope.needsBackup[walletId] = needsBackup;
if (needsBackup) return;
$scope.gettingAddress = true;
$scope.selectedWalletName = walletName;
$timeout(function() {
$scope.$apply();
});
addressService.getAddress(walletId, false, function(err, addr) {
$scope.gettingAddress = false;
@ -261,8 +266,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return;
}
profileService.isBackupNeeded(walletId, function(needsBackup) {
self.destinationWalletNeedsBackup = needsBackup;
$modalInstance.close(addr);
});
});
@ -859,7 +862,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
this.submitForm = function() {
if (!$scope._amount || !$scope._address || self.destinationWalletNeedsBackup) return;
if (!$scope._amount || !$scope._address) return;
var fc = profileService.focusedClient;
var unitToSat = this.unitToSatoshi;
var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
@ -991,7 +994,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.resetForm = function() {
this.resetError();
this.destinationWalletNeedsBackup = null;
this._paypro = null;
this.lockedCurrentFeePerKb = null;

View File

@ -181,18 +181,6 @@ angular.module('copayApp.services')
});
};
root.isBackupNeeded = function(walletId, cb) {
var c = root.getClient(walletId);
if (c.isPrivKeyExternal()) return cb(false);
if (!c.credentials.mnemonic) return cb(false);
if (c.credentials.network == 'testnet') return cb(false);
storageService.getBackupFlag(walletId, function(err, val) {
if (err || val) return cb(false);
return cb(true);
});
};
root._seedWallet = function(opts, cb) {
opts = opts || {};
if (opts.bwsurl)
@ -680,6 +668,18 @@ angular.module('copayApp.services')
});
};
root.isBackupNeeded = function(walletId, cb) {
var c = root.getClient(walletId);
if (c.isPrivKeyExternal()) return cb(false);
if (!c.credentials.mnemonic) return cb(false);
if (c.credentials.network == 'testnet') return cb(false);
storageService.getBackupFlag(walletId, function(err, val) {
if (err || val) return cb(false);
return cb(true);
});
};
root.getWallets = function(network) {
if (!root.profile) return [];