Skip to content
Snippets Groups Projects
Commit b5dd653d authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

fix(tx): TX view: add a delay between many call of showMoreTx()

parent f1aaf841
No related branches found
No related tags found
No related merge requests found
...@@ -687,6 +687,8 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, ...@@ -687,6 +687,8 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location,
'ngInject'; 'ngInject';
$scope.loading = true; $scope.loading = true;
$scope.loadingMore = false;
$scope.lastMoreTxTime = null;
$scope.settings = csSettings.data; $scope.settings = csSettings.data;
$scope.listeners = []; $scope.listeners = [];
$scope.qrcodeId = 'qrcode-wallet-tx-' + $scope.$id; $scope.qrcodeId = 'qrcode-wallet-tx-' + $scope.$id;
...@@ -913,12 +915,19 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location, ...@@ -913,12 +915,19 @@ function WalletTxController($scope, $ionicPopover, $state, $timeout, $location,
return $scope.goState('app.view_wallet_tx_errors_by_id', {id: wallet.id}); return $scope.goState('app.view_wallet_tx_errors_by_id', {id: wallet.id});
}; };
$scope.showMoreTx = function(fromTime) { $scope.showMoreTx = function(fromTime) {
if ($scope.loadingMore) return; // Skip if ($scope.loadingMore) return; // Skip
// Add a delay if previous load has been done recently
var waitDelayMs = $scope.lastMoreTxTime ? Date.now() - $scope.lastMoreTxTime : BMA.constants.LIMIT_REQUEST_DELAY;
if (waitDelayMs > 0 && waitDelayMs < BMA.constants.LIMIT_REQUEST_DELAY) {
return $timeout(function() {
return $scope.showMoreTx(fromTime);
}, waitDelayMs);
}
$scope.loadingMore = true; $scope.loadingMore = true;
$scope.loadingMoreTime = Date.now();
fromTime = fromTime || fromTime = fromTime ||
($scope.formData.tx.fromTime - csSettings.data.walletHistoryTimeSecond) || ($scope.formData.tx.fromTime - csSettings.data.walletHistoryTimeSecond) ||
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment