Skip to content
Snippets Groups Projects
Commit b80374f6 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] My wallets > Clear list after wallet logout

parent 1076364d
No related branches found
No related tags found
No related merge requests found
...@@ -78,7 +78,6 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl ...@@ -78,7 +78,6 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
$scope.settings = csSettings.data; $scope.settings = csSettings.data;
$scope.listeners = []; $scope.listeners = [];
// Initialize the super class and extend it. // Initialize the super class and extend it.
angular.extend(this, $controller('WalletSelectModalCtrl', {$scope: $scope, parameters: {}})); angular.extend(this, $controller('WalletSelectModalCtrl', {$scope: $scope, parameters: {}}));
...@@ -102,28 +101,18 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl ...@@ -102,28 +101,18 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
$scope.showFab('fab-add-wallet'); $scope.showFab('fab-add-wallet');
}); });
} }
else {
//$scope.addListeners();
}
}; };
$scope.$on('$ionicView.enter', $scope.enter); $scope.$on('$ionicView.enter', $scope.enter);
$scope.leave = function() {
//$scope.removeListeners();
};
$scope.$on('$ionicView.leave', $scope.leave);
$scope.cancel = function() { $scope.cancel = function() {
$scope.showHome(); $scope.showHome();
}; };
$scope.select = function(event, wallet) { $scope.select = function(event, wallet) {
if (event.isDefaultPrevented()) return; if (event.isDefaultPrevented()) return;
$state.go('app.view_wallet_by_id', {id: wallet.id}); $state.go('app.view_wallet_by_id', {id: wallet.id});
}; };
$scope.editWallet = function(event, wallet) { $scope.editWallet = function(event, wallet) {
event.preventDefault(); event.preventDefault();
...@@ -373,9 +362,18 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl ...@@ -373,9 +362,18 @@ function WalletListController($scope, $controller, $state, $timeout, $q, $transl
/* -- listeners -- */ /* -- listeners -- */
// Clean controller data when logout
$scope.onWalletLogout = function() {
console.warn("wallet LOGOUT !!!");
$scope.resetData();
$scope.removeListeners();
};
$scope.addListeners = function() { $scope.addListeners = function() {
$scope.listeners =[]; $scope.listeners = [
csWallet.api.data.on.logout($scope, $scope.onWalletLogout)
];
// Auto-update on new block // Auto-update on new block
if (csSettings.data.walletHistoryAutoRefresh) { if (csSettings.data.walletHistoryAutoRefresh) {
...@@ -428,6 +426,7 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl ...@@ -428,6 +426,7 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl
var loadWalletWaitTime = 500; var loadWalletWaitTime = 500;
$scope.loading = true; $scope.loading = true;
$scope.wallets = null;
$scope.formData = { $scope.formData = {
useRelative: csSettings.data.useRelative, useRelative: csSettings.data.useRelative,
showDefault: true, showDefault: true,
...@@ -461,9 +460,9 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl ...@@ -461,9 +460,9 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl
if (!$scope.wallets) { if (!$scope.wallets) {
jobs.push( jobs.push(
csWallet.children.all() csWallet.children.all()
.then(function(children) { .then(function(children) {
$scope.wallets = $scope.formData.showDefault ? [csWallet].concat(children) : children; $scope.wallets = $scope.formData.showDefault ? [csWallet].concat(children) : children;
}) })
); );
} }
...@@ -502,6 +501,7 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl ...@@ -502,6 +501,7 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl
$scope.cancel(); $scope.cancel();
throw err; throw err;
} }
$scope.wallets = [];
$scope.loading = false; $scope.loading = false;
UIUtils.onError('ERROR.LOAD_WALLET_LIST_FAILED')(err); UIUtils.onError('ERROR.LOAD_WALLET_LIST_FAILED')(err);
}); });
...@@ -516,6 +516,12 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl ...@@ -516,6 +516,12 @@ function WalletSelectModalController($scope, $q, $timeout, UIUtils, filterTransl
$scope.closeModal(wallet); $scope.closeModal(wallet);
}; };
// Clean controller data
$scope.resetData = function() {
$scope.wallets = null;
$scope.loading = true;
};
$scope.updateView = function() { $scope.updateView = function() {
if (!$scope.wallets.length) return; if (!$scope.wallets.length) return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment