Refactor the livefeed stop

This commit is contained in:
Chrystian Huot 2020-07-22 09:41:10 -04:00
parent d6bc3c8bcf
commit ec5974cad1

View file

@ -607,13 +607,26 @@ export class AppRdioScannerService implements OnDestroy {
}
private liveFeedStart(): void {
this.liveFeedActive = true;
this.event.emit({ liveFeed: true });
this.webSocketSend(WebSocketCommand.LiveFeedMap, this.liveFeedMap);
}
private liveFeedStop(): void {
this.webSocketSend(WebSocketCommand.LiveFeedMap, null);
this.liveFeedActive = false;
this.callQueue.splice(0, this.callQueue.length);
this.event.emit({
liveFeed: false,
queue: 0,
});
this.stop();
this.webSocketSend(WebSocketCommand.LiveFeedMap, null);
}
private liveFeedStore(): void {
@ -638,10 +651,14 @@ export class AppRdioScannerService implements OnDestroy {
switch (message[2]) {
case WebSocketCallFlag.Download:
this.download(message[1]);
break;
case WebSocketCallFlag.Play:
this.play(message[1]);
if (this.liveFeedActive) {
this.play(message[1]);
}
break;
default:
@ -679,23 +696,6 @@ export class AppRdioScannerService implements OnDestroy {
break;
case WebSocketCommand.LiveFeedMap:
this.liveFeedActive = message[1];
if (this.liveFeedActive) {
this.event.emit({ liveFeed: this.liveFeedActive });
} else {
this.callQueue.splice(0, this.callQueue.length);
this.event.emit({
liveFeed: this.liveFeedActive,
queue: this.callQueue.length,
});
}
break;
case WebSocketCommand.Nop:
clearTimeout(this.webSocketTimeout);