Change ghetto timer to debounce
This commit is contained in:
parent
463a63aed3
commit
4fe3c5e96a
@ -460,23 +460,13 @@ Client.prototype.clientDetach = function(socketId) {
|
||||
delete this.attachedClients[socketId];
|
||||
};
|
||||
|
||||
var timer;
|
||||
Client.prototype.save = function(force) {
|
||||
var client = this;
|
||||
|
||||
Client.prototype.save = _.debounce(function SaveClient() {
|
||||
if (Helper.config.public) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!force) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() {
|
||||
client.save(true);
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
var json = {};
|
||||
const client = this;
|
||||
let json = {};
|
||||
json.networks = this.networks.map(n => n.export());
|
||||
client.manager.updateUser(client.name, json);
|
||||
};
|
||||
}, 1000, {maxWait: 10000});
|
||||
|
Loading…
Reference in New Issue
Block a user