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];
|
delete this.attachedClients[socketId];
|
||||||
};
|
};
|
||||||
|
|
||||||
var timer;
|
Client.prototype.save = _.debounce(function SaveClient() {
|
||||||
Client.prototype.save = function(force) {
|
|
||||||
var client = this;
|
|
||||||
|
|
||||||
if (Helper.config.public) {
|
if (Helper.config.public) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!force) {
|
const client = this;
|
||||||
clearTimeout(timer);
|
let json = {};
|
||||||
timer = setTimeout(function() {
|
|
||||||
client.save(true);
|
|
||||||
}, 1000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var json = {};
|
|
||||||
json.networks = this.networks.map(n => n.export());
|
json.networks = this.networks.map(n => n.export());
|
||||||
client.manager.updateUser(client.name, json);
|
client.manager.updateUser(client.name, json);
|
||||||
};
|
}, 1000, {maxWait: 10000});
|
||||||
|
Loading…
Reference in New Issue
Block a user