ref addresses view
This commit is contained in:
parent
c3dd222c68
commit
8f241b2efc
8 changed files with 75 additions and 39 deletions
|
|
@ -1,32 +1,43 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, lodash, profileService, walletService, bwcError, platformInfo) {
|
||||
var UNUSED_ADDRESS_LIMIT = 5;
|
||||
var BALANCE_ADDRESS_LIMIT = 5;
|
||||
var config;
|
||||
var unitName;
|
||||
var unitToSatoshi;
|
||||
var satToUnit;
|
||||
var unitDecimals;
|
||||
var withBalance;
|
||||
$scope.showInfo = false;
|
||||
$scope.showMore = false;
|
||||
$scope.allAddressesView = false;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var unitName = config.unitName;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var satToUnit = 1 / unitToSatoshi;
|
||||
var unitDecimals = config.unitDecimals;
|
||||
var withBalance, cachedWallet;
|
||||
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
||||
|
||||
function init() {
|
||||
ongoingProcess.set('gettingAddresses', true);
|
||||
function resetValues() {
|
||||
$scope.loading = false;
|
||||
$scope.showInfo = false;
|
||||
$scope.showMore = false;
|
||||
$scope.allAddressesView = false;
|
||||
$scope.latestUnused = $scope.latestWithBalance = null;
|
||||
$scope.viewAll = {
|
||||
value: false
|
||||
};
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
resetValues();
|
||||
$scope.loading = true;
|
||||
|
||||
walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) {
|
||||
if (err) {
|
||||
ongoingProcess.set('gettingAddresses', false);
|
||||
$scope.loading = false;
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
|
||||
var allAddresses = addresses;
|
||||
|
||||
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
||||
ongoingProcess.set('gettingAddresses', false);
|
||||
$scope.loading = false;
|
||||
if (err) {
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
|
|
@ -51,6 +62,10 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
value: $scope.noBalance.length > UNUSED_ADDRESS_LIMIT || withBalance.length > BALANCE_ADDRESS_LIMIT
|
||||
};
|
||||
$scope.allAddresses = $scope.noBalance.concat(withBalance);
|
||||
|
||||
cachedWallet = $scope.wallet.id;
|
||||
$log.debug('Addresses cached for Wallet:', cachedWallet);
|
||||
$ionicScrollDelegate.resize();
|
||||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
|
|
@ -163,20 +178,14 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
});
|
||||
};
|
||||
|
||||
function isCachedWallet(walletId) {
|
||||
if (cachedWallet && cachedWallet == walletId) return true;
|
||||
else return false;
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
});
|
||||
|
||||
$scope.$on("$ionicView.afterEnter", function(event, data) {
|
||||
config = configService.getSync().wallet.settings;
|
||||
unitToSatoshi = config.unitToSatoshi;
|
||||
satToUnit = 1 / unitToSatoshi;
|
||||
unitName = config.unitName;
|
||||
unitDecimals = config.unitDecimals;
|
||||
|
||||
if (!$scope.allAddresses || $scope.allAddresses.length < 0) init();
|
||||
if (!isCachedWallet($stateParams.walletId)) $scope.init();
|
||||
else $log.debug('Addresses cached for Wallet:', $stateParams.walletId);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
|||
'loadingTxInfo': gettext('Loading transaction info...'),
|
||||
'sendingFeedback': gettext('Sending feedback...'),
|
||||
'generatingNewAddress': gettext('Generating new address...'),
|
||||
'gettingAddresses': gettext('Getting addresses...'),
|
||||
'sendingByEmail': gettext('Preparing addresses...'),
|
||||
'sending2faCode': gettext('Sending 2FA code...'),
|
||||
'buyingBitcoin': gettext('Buying Bitcoin...'),
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ input[type=number] {
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.updatingHistory {
|
||||
.updating {
|
||||
div {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue