Fix cache for activity, addressbook, amazon, proposals
This commit is contained in:
parent
1edcf184ee
commit
9cb0dc128c
9 changed files with 68 additions and 41 deletions
|
|
@ -3,12 +3,12 @@
|
|||
angular.module('copayApp.controllers').controller('activityController',
|
||||
function($timeout, $scope, $log, $ionicModal, lodash, txpModalService, profileService, walletService, ongoingProcess, popupService, gettextCatalog) {
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
$scope.fetchingNotifications = true;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.fetchingNotifications = true;
|
||||
$scope.$on("$ionicView.enter", function(event, data){
|
||||
profileService.getNotifications(50, function(err, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
$scope.fetchingNotifications = false;
|
||||
|
|
@ -22,7 +22,7 @@ angular.module('copayApp.controllers').controller('activityController',
|
|||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
$scope.openNotificationModal = function(n) {
|
||||
if (n.txid) {
|
||||
|
|
@ -33,8 +33,16 @@ angular.module('copayApp.controllers').controller('activityController',
|
|||
});
|
||||
if (txp) txpModalService.open(txp);
|
||||
else {
|
||||
$log.warn('No txp found');
|
||||
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
|
||||
ongoingProcess.set('loadingTxInfo', true);
|
||||
walletService.getTxp(n.wallet, n.txpId, function(err, txp) {
|
||||
var _txp = txp;
|
||||
ongoingProcess.set('loadingTxInfo', false);
|
||||
if (err) {
|
||||
$log.warn('No txp found');
|
||||
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
|
||||
}
|
||||
txpModalService.open(_txp);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -56,18 +64,18 @@ angular.module('copayApp.controllers').controller('activityController',
|
|||
return popupService.showAlert(null, gettextCatalog.getString('Transaction not found'));
|
||||
}
|
||||
|
||||
walletService.getTxNote(wallet, n.txid, function(err, note) {
|
||||
if (err) $log.debug(gettextCatalog.getString('Could not fetch transaction note'));
|
||||
$scope.wallet = wallet;
|
||||
$scope.btx = lodash.cloneDeep(tx);
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.txDetailsModal = modal;
|
||||
$scope.txDetailsModal.show();
|
||||
});
|
||||
|
||||
$scope.wallet = wallet;
|
||||
$scope.btx = lodash.cloneDeep(tx);
|
||||
walletService.getTxNote(wallet, n.txid, function(err, note) {
|
||||
if (err) $log.debug('Could not fetch transaction note');
|
||||
$scope.btx.note = note;
|
||||
$ionicModal.fromTemplateUrl('views/modals/tx-details.html', {
|
||||
scope: $scope
|
||||
}).then(function(modal) {
|
||||
$scope.txDetailsModal = modal;
|
||||
$scope.txDetailsModal.show();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('addressbookListController', f
|
|||
|
||||
var contacts;
|
||||
|
||||
$scope.initAddressbook = function() {
|
||||
var initAddressbook = function() {
|
||||
addressbookService.list(function(err, ab) {
|
||||
if (err) $log.error(err);
|
||||
|
||||
|
|
@ -47,10 +47,14 @@ angular.module('copayApp.controllers').controller('addressbookListController', f
|
|||
popupService.showAlert(err);
|
||||
return;
|
||||
}
|
||||
$scope.initAddressbook();
|
||||
initAddressbook();
|
||||
$scope.$digest();
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data){
|
||||
initAddressbook();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
externalLinkService.open(url, target);
|
||||
};
|
||||
|
||||
this.init = function() {
|
||||
var self = this;
|
||||
var initAmazon = function() {
|
||||
$scope.network = amazonService.getEnvironment();
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
if (err) {
|
||||
|
|
@ -20,11 +19,10 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$scope.$digest();
|
||||
});
|
||||
});
|
||||
this.updatePendingGiftCards();
|
||||
}
|
||||
$scope.updatePendingGiftCards();
|
||||
};
|
||||
|
||||
this.updatePendingGiftCards = lodash.debounce(function() {
|
||||
var self = this;
|
||||
$scope.updatePendingGiftCards = lodash.debounce(function() {
|
||||
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
|
|
@ -69,8 +67,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
|
||||
}, 1000);
|
||||
|
||||
this.openCardModal = function(card) {
|
||||
var self = this;
|
||||
$scope.openCardModal = function(card) {
|
||||
$scope.card = card;
|
||||
|
||||
$ionicModal.fromTemplateUrl('views/modals/amazon-card-details.html', {
|
||||
|
|
@ -81,7 +78,11 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
});
|
||||
|
||||
$scope.$on('UpdateAmazonList', function(event) {
|
||||
self.init();
|
||||
initAmazon();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.enter", function(event, data){
|
||||
initAmazon();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('proposalsController',
|
||||
function($timeout, $scope, profileService, $log, txpModalService) {
|
||||
var self = this;
|
||||
|
||||
$scope.fetchingProposals = true;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.$on("$ionicView.enter", function(event, data){
|
||||
profileService.getTxps(50, function(err, txps) {
|
||||
$scope.fetchingProposals = false;
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
$scope.txps = txps;
|
||||
|
|
@ -17,7 +18,7 @@ angular.module('copayApp.controllers').controller('proposalsController',
|
|||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
url: '/activity',
|
||||
views: {
|
||||
'tab-home': {
|
||||
controller: 'activityController',
|
||||
templateUrl: 'views/activity.html',
|
||||
}
|
||||
}
|
||||
|
|
@ -173,6 +174,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
url: '/proposals',
|
||||
views: {
|
||||
'tab-home': {
|
||||
controller: 'proposalsController',
|
||||
templateUrl: 'views/proposals.html',
|
||||
}
|
||||
}
|
||||
|
|
@ -742,6 +744,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
url: '/amazon',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'amazonController',
|
||||
templateUrl: 'views/amazon.html'
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue