Delay save function

This commit is contained in:
Mattias Erming 2014-10-12 02:20:30 +02:00
parent 152395d303
commit 40f8a4ddc4

View File

@ -320,7 +320,18 @@ Client.prototype.quit = function() {
});
};
Client.prototype.save = function() {
var timer;
Client.prototype.save = function(force) {
var client = this;
if (!force) {
clearTimeout(timer);
timer = setTimeout(function() {
client.save(true);
}, 1000);
return;
}
var name = this.name;
var path = Helper.HOME + "/users/" + name + "/user.json";
@ -343,6 +354,7 @@ Client.prototype.save = function() {
json.networks = networks;
} catch(e) {
console.log(e);
return;
}
fs.writeFile(