add debounce

This commit is contained in:
Matias Alejo Garcia 2014-10-31 15:49:56 -03:00
commit 5adc4fd5d2
2 changed files with 22 additions and 23 deletions

View file

@ -580,6 +580,7 @@ Wallet.prototype.updateFocusedTimestamp = function(ts) {
this.focusedTimestamp = ts;
};
Wallet.prototype.updateSyncedTimestamp = function(ts) {
preconditions.checkArgument(ts);
preconditions.checkArgument(_.isNumber(ts));
@ -588,7 +589,6 @@ Wallet.prototype.updateSyncedTimestamp = function(ts) {
};
/**
* @desc Called when there are no messages in the server
* Triggers a call to {@link Wallet#sendWalletReady}
@ -617,6 +617,7 @@ Wallet.prototype._onData = function(senderId, data, ts) {
preconditions.checkArgument(_.isNumber(ts));
log.debug('Wallet:' + this.id + ' RECV', senderId, data);
this.updateSyncedTimestamp(ts);
if (data.type !== 'walletId' && this.id !== data.walletId) {
@ -631,7 +632,6 @@ Wallet.prototype._onData = function(senderId, data, ts) {
this.sendWalletReady(senderId);
break;
case 'walletReady':
if (this.lastMessageFrom[senderId] !== 'walletReady') {
log.debug('Wallet:' + this.id + ' peer Sync received. since: ' + (data.sinceTs || 0));
this.sendPublicKeyRing(senderId);