refactor clear history method call

This commit is contained in:
Javier 2015-10-30 12:47:37 -03:00
parent c20cccedc2
commit 7c21793236
3 changed files with 18 additions and 16 deletions

View File

@ -113,7 +113,7 @@
<ul class="no-bullet m0 size-14">
<h4 class="title m0" translate>Transaction history</h4>
<li class="line-b p20 oh">
<button class="black round small expand" ng-style="{'background-color':index.backgroundColor}" ng-click="info.clearTransactionHistory(); index.clearHistoryFeedback();">
<button class="black round small expand" ng-style="{'background-color':index.backgroundColor}" ng-click="info.clearTransactionHistory();">
<span translate>Clear history</span>
</button>
</li>

View File

@ -910,19 +910,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
};
self.clearHistoryFeedback = function() {
self.txHistory = [];
$log.debug('The wallet transaction history has been deleted');
self.setOngoingProcess('deletingHistory', true);
self.updateHistory();
go.walletHome();
$timeout(function() {
self.setOngoingProcess('deletingHistory', false);
}, 2000);
};
self.setUxLanguage = function() {
var userLang = uxLanguage.update();
self.defaultLanguageIsoCode = userLang;
@ -1018,6 +1005,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
};
// UX event handlers
$rootScope.$on('Local/ClearHistory', function(event, walletId) {
storageService.removeTxHistory(walletId, function(err) {
if (err) root.showErrorPopup(err);
$log.debug('The wallet transaction history has been deleted');
self.txHistory = [];
self.updateHistory();
});
});
$rootScope.$on('Local/ColorUpdated', function(event) {
self.updateColor();
$timeout(function() {

View File

@ -95,8 +95,13 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
};
this.clearTransactionHistory = function() {
storageService.removeTxHistory(c.walletId, function() {
return;
storageService.removeTxHistory(c.walletId, function(err) {
if (err) return $log.err(err);
$timeout(function() {
$scope.$emit('Local/ClearHistory');
go.walletHome();
}, 100);
});
}
});