add checksum on close

This commit is contained in:
Ivan Socolsky 2015-01-07 19:59:35 -03:00
parent a8923d2a69
commit 5255d4ba31
2 changed files with 22 additions and 9 deletions

View File

@ -460,9 +460,26 @@ Identity.prototype._cleanUp = function() {
/**
* @desc Closes the wallet and disconnects all services
*/
Identity.prototype.close = function() {
this._cleanUp();
this.emitAndKeepAlive('closed');
Identity.prototype.close = function(cb) {
var self = this;
function doClose() {
self._cleanUp();
self.emitAndKeepAlive('closed');
if (cb) return cb();
};
self.verifyChecksum(function(err, match) {
if (!err && match) {
self.store({
noWallets: true,
}, function(err) {
return doClose();
});
} else {
return doClose();
}
});
};

View File

@ -322,12 +322,8 @@ angular.module('copayApp.services')
root.signout = function() {
$rootScope.signingOut = true;
if ($rootScope.iden) {
$rootScope.iden.store({
noWallets: true
}, function() {
$rootScope.signingOut = false;
$rootScope.iden.close(); // Will trigger 'closed'
});
$rootScope.signingOut = false;
$rootScope.iden.close(); // Will trigger 'closed'
}
};