Merged.
This commit is contained in:
commit
95de043d3d
2 changed files with 51 additions and 43 deletions
|
|
@ -13,6 +13,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
gettingCachedHistory: true,
|
gettingCachedHistory: true,
|
||||||
gettingInitialHistory: true,
|
gettingInitialHistory: true,
|
||||||
updatingTxHistory: false,
|
updatingTxHistory: false,
|
||||||
|
fetchedAllTxHistory: false,
|
||||||
//updateTxHistoryError: false
|
//updateTxHistoryError: false
|
||||||
updateTxHistoryFailed: false
|
updateTxHistoryFailed: false
|
||||||
};
|
};
|
||||||
|
|
@ -108,6 +109,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
$scope.updatingStatus = true;
|
$scope.updatingStatus = true;
|
||||||
$scope.updateStatusError = null;
|
$scope.updateStatusError = null;
|
||||||
$scope.walletNotRegistered = false;
|
$scope.walletNotRegistered = false;
|
||||||
|
$scope.vm.fetchedAllTxHistory = false;
|
||||||
|
|
||||||
walletService.getStatus($scope.wallet, {
|
walletService.getStatus($scope.wallet, {
|
||||||
force: !!force,
|
force: !!force,
|
||||||
|
|
@ -198,44 +200,6 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var updateTxHistory = function(cb) {
|
|
||||||
if (!cb) cb = function() {};
|
|
||||||
$scope.vm.updateTxHistoryFailed = false;
|
|
||||||
$scope.updatingTxHistoryProgress = 0;
|
|
||||||
|
|
||||||
feeService.getFeeLevels($scope.wallet.coin, function(err, levels) {
|
|
||||||
walletService.getTxHistory($scope.wallet, {
|
|
||||||
feeLevels: levels
|
|
||||||
}, function(err, txHistory) {
|
|
||||||
$scope.vm.gettingInitialHistory = false;
|
|
||||||
if (err) {
|
|
||||||
$scope.txHistory = null;
|
|
||||||
$scope.vm.updateTxHistoryFailed = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyCurrencyAliases(txHistory);
|
|
||||||
|
|
||||||
var config = configService.getSync();
|
|
||||||
var fiatCode = config.wallet.settings.alternativeIsoCode;
|
|
||||||
lodash.each(txHistory, function(t) {
|
|
||||||
var r = rateService.toFiat(t.amount, fiatCode, $scope.wallet.coin);
|
|
||||||
t.alternativeAmountStr = r.toFixed(2) + ' ' + fiatCode;
|
|
||||||
});
|
|
||||||
console.log('pagination Got tx history old way');
|
|
||||||
completeTxHistory = txHistory;
|
|
||||||
|
|
||||||
//$scope.showHistory();
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$apply();
|
|
||||||
});
|
|
||||||
return cb();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
function applyCurrencyAliases(txHistory) {
|
function applyCurrencyAliases(txHistory) {
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
var configCache = configService.getSync();
|
var configCache = configService.getSync();
|
||||||
|
|
@ -290,7 +254,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
console.log('pagination fetchAndShowTxHistory() getLatest:', getLatest, ', flushCacheOnNew:', flushCacheOnNew);
|
console.log('pagination fetchAndShowTxHistory() getLatest:', getLatest, ', flushCacheOnNew:', flushCacheOnNew);
|
||||||
$scope.vm.updatingTxHistory = true;
|
$scope.vm.updatingTxHistory = true;
|
||||||
|
|
||||||
walletHistoryService.updateLocalTxHistoryByPage($scope.wallet, getLatest, flushCacheOnNew, function onUpdateLocalTxHistoryByPage(err, txHistory) {
|
walletHistoryService.updateLocalTxHistoryByPage($scope.wallet, getLatest, flushCacheOnNew, function onUpdateLocalTxHistoryByPage(err, txHistory, fetchedAllTransactions) {
|
||||||
console.log('pagination returned');
|
console.log('pagination returned');
|
||||||
$scope.vm.gettingInitialHistory = false;
|
$scope.vm.gettingInitialHistory = false;
|
||||||
$scope.vm.updatingTxHistory = false;
|
$scope.vm.updatingTxHistory = false;
|
||||||
|
|
@ -301,6 +265,12 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
$scope.vm.updateTxHistoryFailed = true;
|
$scope.vm.updateTxHistoryFailed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fetchedAllTransactions) {
|
||||||
|
console.log("All transactions seem to be fetched..");
|
||||||
|
$scope.vm.fetchedAllTxHistory = true;
|
||||||
|
}
|
||||||
|
|
||||||
console.log('pagination txs returned in history: ' + txHistory.length);
|
console.log('pagination txs returned in history: ' + txHistory.length);
|
||||||
formatTxHistoryForDisplay(txHistory);
|
formatTxHistoryForDisplay(txHistory);
|
||||||
|
|
||||||
|
|
@ -314,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 = completeTxHistory.length > $scope.txHistory.length || !$scope.vm.gettingInitialHistory;
|
$scope.vm.allowInfiniteScroll = !$scope.vm.fetchedAllTxHistory;//(completeTxHistory.length > $scope.txHistory.length || !$scope.vm.gettingInitialHistory) || (!$scope.vm.gettingInitialHistory && !$scope.vm.fetchedAllTxHistory);
|
||||||
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;
|
||||||
|
|
@ -534,7 +504,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
updateTxHistoryFromCachedData();
|
updateTxHistoryFromCachedData();
|
||||||
$scope.updateAll(false, true);
|
$scope.updateAll(false, true);
|
||||||
refreshAmountSection();
|
refreshAmountSection();
|
||||||
//refreshInterval = $interval($scope.onRefresh, 10 * 1000);
|
refreshInterval = $interval($scope.onRefresh, 10 * 1000);
|
||||||
//refreshInterval = $interval($scope.onRefresh, 120 * 1000); // For testing
|
//refreshInterval = $interval($scope.onRefresh, 120 * 1000); // For testing
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,46 @@
|
||||||
|
|
||||||
var SAFE_CONFIRMATIONS = 6;
|
var SAFE_CONFIRMATIONS = 6;
|
||||||
|
|
||||||
|
var allTransactionsFetched = false;
|
||||||
var service = {
|
var service = {
|
||||||
getCachedTxHistory: getCachedTxHistory,
|
getCachedTxHistory: getCachedTxHistory,
|
||||||
updateLocalTxHistoryByPage: updateLocalTxHistoryByPage,
|
updateLocalTxHistoryByPage: updateLocalTxHistoryByPage,
|
||||||
};
|
};
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
|
/*
|
||||||
|
function hasAllTransactionsFetched(walletId, cachedTxs, newTxs) {
|
||||||
|
var cachedTxIds = {};
|
||||||
|
cachedTxs.forEach(function forCachedTx(tx){
|
||||||
|
cachedTxIds[tx.txid] = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
var someTransactionWereNew = false;
|
||||||
|
var overlappingTxsCount = 0;
|
||||||
|
|
||||||
|
newTxs.forEach(function forNewTx(tx){
|
||||||
|
if (cachedTxIds[tx.txid]) {
|
||||||
|
overlappingTxsCount++;
|
||||||
|
} else {
|
||||||
|
someTransactionWereNew = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('pagination Overlapping transactions:', overlappingTxsCount);
|
||||||
|
if (overlappingTxsCount >= MIN_KNOWN_TX_OVERLAP) { // We are good
|
||||||
|
if (!someTransactionWereNew && overlappingTxsCount === newTxs.length) {
|
||||||
|
console.log("We probably have all of the transactions fetched!!")
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("Something went wrong")
|
||||||
|
return true; // Something went wrong, so stop fetching..
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
function addEarlyTransactions(walletId, cachedTxs, newTxs) {
|
function addEarlyTransactions(walletId, cachedTxs, newTxs) {
|
||||||
|
|
||||||
var cachedTxIds = {};
|
var cachedTxIds = {};
|
||||||
|
|
@ -48,6 +82,9 @@
|
||||||
if (someTransactionsWereNew) {
|
if (someTransactionsWereNew) {
|
||||||
console.log('pagination someTransactionsWereNew');
|
console.log('pagination someTransactionsWereNew');
|
||||||
saveTxHistory(walletId, cachedTxs);
|
saveTxHistory(walletId, cachedTxs);
|
||||||
|
} else if (overlappingTxsCount === newTxs.length) {
|
||||||
|
console.log('We probably have all transactions now');
|
||||||
|
allTransactionsFetched = true;
|
||||||
}
|
}
|
||||||
return cachedTxs;
|
return cachedTxs;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -225,7 +262,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetchedTxs.length === 0) {
|
if (fetchedTxs.length === 0) {
|
||||||
return cb(null, cachedTxs);
|
return cb(null, cachedTxs, true /*fetchedAllTransactions*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
var txs = [];
|
var txs = [];
|
||||||
|
|
@ -233,11 +270,12 @@
|
||||||
txs = addLatestTransactions(wallet.id, cachedTxs, fetchedTxs);
|
txs = addLatestTransactions(wallet.id, cachedTxs, fetchedTxs);
|
||||||
} else {
|
} else {
|
||||||
txs = addEarlyTransactions(wallet.id, cachedTxs, fetchedTxs);
|
txs = addEarlyTransactions(wallet.id, cachedTxs, fetchedTxs);
|
||||||
|
return cb(null, txs, allTransactionsFetched/*, hasAllTransactionsFetched(wallet.id, cachedTxs, fetchedTxs)*/);
|
||||||
}
|
}
|
||||||
return cb(null, txs);
|
return cb(null, txs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue