Displaying more cached data while waiting for first tx history fetch.

This commit is contained in:
Brendon Duncan 2018-08-22 19:51:10 +12:00
commit e6beb6fed1

View file

@ -267,7 +267,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
} }
if (fetchedAllTransactions) { if (fetchedAllTransactions) {
console.log("All transactions seem to be fetched.."); console.log("pagination Fetched all transactions.");
$scope.vm.fetchedAllTxHistory = true; $scope.vm.fetchedAllTxHistory = true;
} }
@ -284,7 +284,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
function showHistory(showAll) { function showHistory(showAll) {
if (completeTxHistory) { if (completeTxHistory) {
$scope.txHistory = showAll ? completeTxHistory : completeTxHistory.slice(0, (currentTxHistoryDisplayPage + 1) * DISPLAY_PAGE_SIZE); $scope.txHistory = showAll ? completeTxHistory : completeTxHistory.slice(0, (currentTxHistoryDisplayPage + 1) * DISPLAY_PAGE_SIZE);
$scope.vm.allowInfiniteScroll = !$scope.vm.fetchedAllTxHistory;//(completeTxHistory.length > $scope.txHistory.length || !$scope.vm.gettingInitialHistory) || (!$scope.vm.gettingInitialHistory && !$scope.vm.fetchedAllTxHistory); $scope.vm.allowInfiniteScroll = !$scope.vm.fetchedAllTxHistory && !(completeTxHistory.length === $scope.txHistory.length && $scope.vm.gettingInitialHistory);
console.log('pagination Showing txs: ', $scope.txHistory.length); console.log('pagination Showing txs: ', $scope.txHistory.length);
} else { } else {
$scope.vm.allowInfiniteScroll = false; $scope.vm.allowInfiniteScroll = false;
@ -332,18 +332,19 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
// on-infinite="showMore()" // on-infinite="showMore()"
$scope.showMore = function() { $scope.showMore = function() {
console.log('pagination showMore()'); console.log('pagination showMore()');
if ($scope.vm.updatingTxHistory) {
return;
}
// Check if we have more than we are displaying // Check if we have more than we are displaying
if (completeTxHistory.length > $scope.txHistory.length) { if (completeTxHistory.length > $scope.txHistory.length) {
console.log('pagination We have more data than we are displaying.');
currentTxHistoryDisplayPage++; currentTxHistoryDisplayPage++;
showHistory(false); showHistory(false);
$scope.$broadcast('scroll.infiniteScrollComplete'); $scope.$broadcast('scroll.infiniteScrollComplete');
return; return;
} }
if ($scope.vm.updatingTxHistory) {
return;
}
fetchAndShowTxHistory(false, false); fetchAndShowTxHistory(false, false);
}; };