diff --git a/CHANGELOG.md b/CHANGELOG.md index 7319b6a..818a69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ - Add load-tr to load Trunk Recorder talkgroups csv. - Move back keypadsBeeps presets to backend. - Change config.options.useDimmer to config.options.dimmerDelay. +- Fix potential error in handling keypadBeeps styles. +- Change handling of skip delay on client. # Version 4.6 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 d1d10bd..9f4d1c9 100644 --- a/client/src/app/components/rdio-scanner/rdio-scanner.service.ts +++ b/client/src/app/components/rdio-scanner/rdio-scanner.service.ts @@ -85,6 +85,8 @@ export class AppRdioScannerService implements OnDestroy { private liveFeedMapPriorToHoldTalkgroup: RdioScannerLiveFeedMap | undefined; private liveFeedPaused = false; + private skipDelay = false; + private webSocket: WebSocket | undefined; private webSocketMessagePending = false; @@ -349,8 +351,8 @@ export class AppRdioScannerService implements OnDestroy { this.event.emit({ pause: this.liveFeedPaused }); } - play(call?: RdioScannerCall | undefined, options?: { delay?: boolean }): void { - if (this.liveFeedPaused) { + play(call?: RdioScannerCall | undefined): void { + if (this.liveFeedPaused || this.skipDelay) { return; } else if (call?.audio) { @@ -379,30 +381,28 @@ export class AppRdioScannerService implements OnDestroy { } this.audioContext?.decodeAudioData(arrayBuffer, (buffer) => { - timer(options?.delay ? 1000 : 0).subscribe(() => { - if (!this.audioContext || this.audioSource || !this.call) { - return; - } + if (!this.audioContext || this.audioSource || !this.call) { + return; + } - this.audioSource = this.audioContext.createBufferSource(); - this.audioSource.buffer = buffer; - this.audioSource.connect(this.audioContext.destination); - this.audioSource.onended = () => this.skip({ delay: true }); - this.audioSource.start(); + this.audioSource = this.audioContext.createBufferSource(); + this.audioSource.buffer = buffer; + this.audioSource.connect(this.audioContext.destination); + this.audioSource.onended = () => this.skip({ delay: true }); + this.audioSource.start(); - this.event.emit({ call: this.call, queue: this.callQueue.length }); + this.event.emit({ call: this.call, queue: this.callQueue.length }); - interval(500).pipe(takeWhile(() => !!this.call)).subscribe(() => { - if (this.audioContext && !isNaN(this.audioContext.currentTime)) { - if (isNaN(this.audioSourceStartTime)) { - this.audioSourceStartTime = this.audioContext.currentTime; - } - - if (!this.liveFeedPaused) { - this.event.emit({ time: this.audioContext.currentTime - this.audioSourceStartTime }); - } + interval(500).pipe(takeWhile(() => !!this.call)).subscribe(() => { + if (this.audioContext && !isNaN(this.audioContext.currentTime)) { + if (isNaN(this.audioSourceStartTime)) { + this.audioSourceStartTime = this.audioContext.currentTime; } - }); + + if (!this.liveFeedPaused) { + this.event.emit({ time: this.audioContext.currentTime - this.audioSourceStartTime }); + } + } }); }, () => { this.event.emit({ call: this.call, queue: this.callQueue.length }); @@ -425,7 +425,7 @@ export class AppRdioScannerService implements OnDestroy { } replay(): void { - this.play(this.call || this.callPrevious, { delay: false }); + this.play(this.call || this.callPrevious); } searchCalls(options: RdioScannerSearchOptions): void { @@ -435,7 +435,18 @@ export class AppRdioScannerService implements OnDestroy { skip(options?: { delay?: boolean }): void { this.stop(); - this.play(undefined, options); + if (options?.delay) { + this.skipDelay = true; + + timer(1000).subscribe(() => { + this.skipDelay = false; + + this.play(); + }); + + } else { + this.play(); + } } stop(options?: { emit?: boolean }): void {