add cache sync
This commit is contained in:
parent
28eb3ee989
commit
d7e8ca4404
2 changed files with 42 additions and 31 deletions
|
|
@ -757,8 +757,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
|
|
||||||
var confirmedTxs = self.removeAndMarkSoftConfirmedTx(txsFromLocal);
|
var confirmedTxs = self.removeAndMarkSoftConfirmedTx(txsFromLocal);
|
||||||
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
var endingTxid = confirmedTxs[0] ? confirmedTxs[0].txid : null;
|
||||||
var endingTs = confirmedTxs[0] ? confirmedTxs[0].ts : null;
|
var endingTs = confirmedTxs[0] ? confirmedTxs[0].time : null;
|
||||||
console.log('[index.js.760:endingTs:]',endingTs); //TODO
|
|
||||||
|
|
||||||
|
|
||||||
// First update
|
// First update
|
||||||
|
|
@ -813,24 +812,52 @@ console.log('[index.js.760:endingTs:]',endingTs); //TODO
|
||||||
var newHistory = lodash.uniq(lodash.compact(txs.concat(confirmedTxs)), function(x) {
|
var newHistory = lodash.uniq(lodash.compact(txs.concat(confirmedTxs)), function(x) {
|
||||||
return x.txid;
|
return x.txid;
|
||||||
});
|
});
|
||||||
var historyToSave = JSON.stringify(newHistory);
|
|
||||||
|
|
||||||
lodash.each(txs, function(tx) {
|
|
||||||
tx.recent = true;
|
|
||||||
})
|
|
||||||
|
|
||||||
$log.debug('Tx History synced. Total Txs: ' + newHistory.length);
|
function updateNotes(cb2) {
|
||||||
|
if (!endingTs) return cb2();
|
||||||
|
|
||||||
// Final update
|
$log.debug('Syncing notes from: ' + endingTs);
|
||||||
if (walletId == profileService.focusedClient.credentials.walletId) {
|
client.getTxNotes({
|
||||||
self.completeHistory = newHistory;
|
minTs: endingTs
|
||||||
self.setCompactTxHistory();
|
}, function(err, notes) {
|
||||||
|
if (err) {
|
||||||
|
$log.warn(err);
|
||||||
|
return cb2();
|
||||||
|
};
|
||||||
|
lodash.each(notes, function(note) {
|
||||||
|
$log.debug('Note for ' + note.txid);
|
||||||
|
lodash.each(newHistory, function(tx) {
|
||||||
|
if (tx.txid == note.txid) {
|
||||||
|
$log.debug('...updating note for ' + note.txid);
|
||||||
|
tx.note = note;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return cb2();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return storageService.setTxHistory(historyToSave, walletId, function() {
|
updateNotes(function() {
|
||||||
$log.debug('Tx History saved.');
|
var historyToSave = JSON.stringify(newHistory);
|
||||||
|
|
||||||
return cb();
|
lodash.each(txs, function(tx) {
|
||||||
|
tx.recent = true;
|
||||||
|
})
|
||||||
|
|
||||||
|
$log.debug('Tx History synced. Total Txs: ' + newHistory.length);
|
||||||
|
|
||||||
|
// Final update
|
||||||
|
if (walletId == profileService.focusedClient.credentials.walletId) {
|
||||||
|
self.completeHistory = newHistory;
|
||||||
|
self.setCompactTxHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return storageService.setTxHistory(historyToSave, walletId, function() {
|
||||||
|
$log.debug('Tx History saved.');
|
||||||
|
|
||||||
|
return cb();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,22 +12,6 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
|
||||||
$scope.color = fc.backgroundColor;
|
$scope.color = fc.backgroundColor;
|
||||||
$scope.copayerId = fc.credentials.copayerId;
|
$scope.copayerId = fc.credentials.copayerId;
|
||||||
$scope.isShared = fc.credentials.n > 1;
|
$scope.isShared = fc.credentials.n > 1;
|
||||||
|
|
||||||
console.log('[txDetails.js.16:btx:]',$scope.btx); //TODO
|
|
||||||
// if ($scope.btx.txid) {
|
|
||||||
// fc.getTxNote({
|
|
||||||
// txid: $scope.btx.txid
|
|
||||||
// }, function(err, note) {
|
|
||||||
// if (err || !note) {
|
|
||||||
// $log.debug(gettextCatalog.getString('Could not fetch transaction note'));
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// $scope.comment = note.body;
|
|
||||||
// $scope.editedBy = gettextCatalog.getString('Edited by') + ' ' + note.editedByName;
|
|
||||||
// $scope.createdOn = note.createdOn;
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
$scope.showCommentPopup = function() {
|
$scope.showCommentPopup = function() {
|
||||||
$scope.data = {
|
$scope.data = {
|
||||||
comment: ''
|
comment: ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue