From bbb3acdca1cfd6fb7edce01700c32be6e15818e5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Wed, 18 Jan 2017 12:09:17 -0300 Subject: [PATCH] fix delete tx history --- src/js/controllers/preferencesHistory.js | 11 +++++++++-- src/js/services/walletService.js | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/preferencesHistory.js b/src/js/controllers/preferencesHistory.js index 32f4375cc..68c6f8daa 100644 --- a/src/js/controllers/preferencesHistory.js +++ b/src/js/controllers/preferencesHistory.js @@ -1,12 +1,14 @@ 'use strict'; 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.csvReady = false; $scope.isCordova = platformInfo.isCordova; $scope.appName = appConfigService.nameCase; + + // TODO : move this to walletService. $scope.csvHistory = function(cb) { var allTxs = []; @@ -123,12 +125,17 @@ angular.module('copayApp.controllers').controller('preferencesHistory', }; $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) { $log.error(err); return; } + $log.info('Transaction history cleared for :' + $scope.wallet.id); + $ionicHistory.removeBackView(); $state.go('tabs.home'); $timeout(function() { diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 236b19ee1..44209b3d3 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -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) { opts = opts || {};