fix delete tx history

This commit is contained in:
Matias Alejo Garcia 2017-01-18 12:09:17 -03:00
parent bca128a7ff
commit bbb3acdca1
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
2 changed files with 24 additions and 2 deletions

View File

@ -1,12 +1,14 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('preferencesHistory', angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, storageService, platformInfo, profileService, lodash, appConfigService) { function($scope, $log, $stateParams, $timeout, $state, $ionicHistory, storageService, platformInfo, profileService, lodash, appConfigService, walletService) {
$scope.wallet = profileService.getWallet($stateParams.walletId); $scope.wallet = profileService.getWallet($stateParams.walletId);
$scope.csvReady = false; $scope.csvReady = false;
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
$scope.appName = appConfigService.nameCase; $scope.appName = appConfigService.nameCase;
// TODO : move this to walletService.
$scope.csvHistory = function(cb) { $scope.csvHistory = function(cb) {
var allTxs = []; var allTxs = [];
@ -123,12 +125,17 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
}; };
$scope.clearTransactionHistory = function() { $scope.clearTransactionHistory = function() {
storageService.removeTxHistory($scope.wallet.id, function(err) { $log.info('Removing Transaction history ' + $scope.wallet.id);
walletService.clearTxHistory($scope.wallet, function(err) {
if (err) { if (err) {
$log.error(err); $log.error(err);
return; return;
} }
$log.info('Transaction history cleared for :' + $scope.wallet.id);
$ionicHistory.removeBackView(); $ionicHistory.removeBackView();
$state.go('tabs.home'); $state.go('tabs.home');
$timeout(function() { $timeout(function() {

View File

@ -551,6 +551,21 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
}; };
}; };
root.clearTxHistory = function(wallet, cb) {
root.invalidateCache(wallet);
storageService.removeTxHistory(wallet.id, function(err) {
if (err) {
$log.error(err);
return cb();
}
return cb();
});
};
root.getTxHistory = function(wallet, opts, cb) { root.getTxHistory = function(wallet, opts, cb) {
opts = opts || {}; opts = opts || {};