From ec5974cad138c9f106ab9e27632966e6ecb5fdad Mon Sep 17 00:00:00 2001 From: Chrystian Huot Date: Wed, 22 Jul 2020 09:41:10 -0400 Subject: [PATCH] Refactor the livefeed stop --- .../rdio-scanner/rdio-scanner.service.ts | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/client/src/app/components/rdio-scanner/rdio-scanner.service.ts b/client/src/app/components/rdio-scanner/rdio-scanner.service.ts index 0b01562..4dc512e 100644 --- a/client/src/app/components/rdio-scanner/rdio-scanner.service.ts +++ b/client/src/app/components/rdio-scanner/rdio-scanner.service.ts @@ -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);