Better queue management

This commit is contained in:
Chrystian Huot 2019-06-17 07:41:02 -04:00
parent ac6c1c985a
commit 575c6ec1fc

View file

@ -134,6 +134,10 @@ export class AppRadioService implements OnDestroy {
this._hold.system = this._hold.system === null ? call.systemData || call.system : null;
this._emitHoldEvent(this._hold.system === null ? '-sys' : '+sys');
if (this._hold.system !== null) {
this._cleanQueue();
}
}
}
@ -144,6 +148,10 @@ export class AppRadioService implements OnDestroy {
this._hold.talkgroup = this._hold.talkgroup === null ? call.talkgroupData || call.talkgroup : null;
this._emitHoldEvent(this._hold.talkgroup === null ? '-tg' : '+tg');
if (this._hold.talkgroup !== null) {
this._cleanQueue();
}
}
}
@ -157,6 +165,8 @@ export class AppRadioService implements OnDestroy {
this._emitLiveEvent();
this._flushQueue();
this.stop();
}
this._writeLive();
@ -256,6 +266,16 @@ export class AppRadioService implements OnDestroy {
}
}
private _cleanQueue(): void {
const queueLength = this._call.queue.length;
this._call.queue = this._call.queue.filter((_call: RadioCall) => !this._callFiltered(_call));
if (queueLength !== this._call.queue.length) {
this._emitQueueEvent();
}
}
private _configureAudio(): void {
const stopHandler = () => {
if (this._call.current) {