mirror of https://github.com/BTCPrivate/copay.git
give lock preference to the new instance
This commit is contained in:
parent
18aadede29
commit
1a5a2916c2
|
@ -89,7 +89,7 @@ path: '/',
|
||||||
verbose: 1,
|
verbose: 1,
|
||||||
// will duplicate itself after each try
|
// will duplicate itself after each try
|
||||||
reconnectDelay: 5000,
|
reconnectDelay: 5000,
|
||||||
idleDurationMin: 1
|
idleDurationMin: 4
|
||||||
},
|
},
|
||||||
|
|
||||||
// blockchain service API config
|
// blockchain service API config
|
||||||
|
|
|
@ -10,7 +10,7 @@ function WalletLock(storage, walletId, timeoutMin) {
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.timeoutMin = timeoutMin || 5;
|
this.timeoutMin = timeoutMin || 5;
|
||||||
this.key = WalletLock._keyFor(walletId);
|
this.key = WalletLock._keyFor(walletId);
|
||||||
this.keepAlive();
|
this._setLock();
|
||||||
}
|
}
|
||||||
WalletLock._keyFor = function(walletId) {
|
WalletLock._keyFor = function(walletId) {
|
||||||
return 'lock' + '::' + walletId;
|
return 'lock' + '::' + walletId;
|
||||||
|
@ -29,17 +29,21 @@ WalletLock.prototype._isLockedByOther = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
WalletLock.prototype._setLock = function() {
|
||||||
|
this.storage.setGlobal(this.key, {
|
||||||
|
sessionId: this.sessionId,
|
||||||
|
expireTs: Date.now() + this.timeoutMin * 60 * 1000,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
WalletLock.prototype.keepAlive = function() {
|
WalletLock.prototype.keepAlive = function() {
|
||||||
preconditions.checkState(this.sessionId);
|
preconditions.checkState(this.sessionId);
|
||||||
|
|
||||||
var t = this._isLockedByOther();
|
var t = this._isLockedByOther();
|
||||||
if (t)
|
if (t)
|
||||||
throw new Error('Wallet is already open. Close it to proceed or wait '+ t + ' seconds if you close it already' );
|
throw new Error('Wallet is already open. Close it to proceed or wait '+ t + ' seconds if you close it already' );
|
||||||
|
this._setLock();
|
||||||
this.storage.setGlobal(this.key, {
|
|
||||||
sessionId: this.sessionId,
|
|
||||||
expireTs: Date.now() + this.timeoutMin * 60 * 1000,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ angular
|
||||||
var timeout = config.wallet.idleDurationMin * 60 || 300;
|
var timeout = config.wallet.idleDurationMin * 60 || 300;
|
||||||
$idleProvider.idleDuration(timeout); // in seconds
|
$idleProvider.idleDuration(timeout); // in seconds
|
||||||
$idleProvider.warningDuration(20); // in seconds
|
$idleProvider.warningDuration(20); // in seconds
|
||||||
$keepaliveProvider.interval(5); // in seconds
|
$keepaliveProvider.interval(2); // in seconds
|
||||||
})
|
})
|
||||||
.run(function($rootScope, $location, $idle) {
|
.run(function($rootScope, $location, $idle) {
|
||||||
$idle.watch();
|
$idle.watch();
|
||||||
|
|
Loading…
Reference in New Issue