Cleanup of clearTimeout and nonasync funcs

This commit is contained in:
John Lindahl 2021-01-13 19:43:11 +01:00 committed by GitHub
parent 8fda4a8d61
commit 7bc4801289
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,7 +98,7 @@ class PlejdService extends EventEmitter {
}; };
clearInterval(this.pingRef); clearInterval(this.pingRef);
clearInterval(this.writeQueueRef); clearTimeout(this.writeQueueRef);
console.log('init()'); console.log('init()');
const bluez = await this.bus.getProxyObject(BLUEZ_SERVICE_NAME, '/'); const bluez = await this.bus.getProxyObject(BLUEZ_SERVICE_NAME, '/');
@ -369,8 +369,8 @@ class PlejdService extends EventEmitter {
} }
// auth done, start ping // auth done, start ping
await this.startPing(); this.startPing();
await this.startWriteQueue(); this.startWriteQueue();
// After we've authenticated, we need to hook up the event listener // After we've authenticated, we need to hook up the event listener
// for changes to lastData. // for changes to lastData.
@ -414,7 +414,7 @@ class PlejdService extends EventEmitter {
} }
} }
async startPing() { startPing() {
console.log('startPing()'); console.log('startPing()');
clearInterval(this.pingRef); clearInterval(this.pingRef);
@ -460,9 +460,9 @@ class PlejdService extends EventEmitter {
this.emit('pingSuccess', pong[0]); this.emit('pingSuccess', pong[0]);
} }
async startWriteQueue() { startWriteQueue() {
console.log('startWriteQueue()'); console.log('startWriteQueue()');
clearInterval(this.writeQueueRef); clearTimeout(this.writeQueueRef);
this.writeQueueRef = setTimeout(() => this.runWriteQueue(), this.writeQueueWaitTime); this.writeQueueRef = setTimeout(() => this.runWriteQueue(), this.writeQueueWaitTime);
} }