Optimized stopping the scanner.

This commit is contained in:
Marat Fayzullin 2023-05-13 13:16:12 -04:00
parent 6d6b8c7d16
commit 95fb8b8dda
2 changed files with 13 additions and 4 deletions

View File

@ -109,3 +109,8 @@ Scanner.prototype.toggle = function() {
// Toggle based on the current timer state
return this.timer? this.stop() : this.start();
};
Scanner.prototype.isRunning = function() {
// Return current state
return this.timer != null;
};

View File

@ -1722,10 +1722,14 @@ function toggleSpectrum() {
}
function stopScanner() {
var $scanButton = $('.openwebrx-squelch-auto');
$scanButton.css('animation-name', '');
$scanButton.removeClass('highlighted');
scanner.stop();
if (scanner.isRunning()) {
// Stop scanner
scanner.stop();
// Modify scanner button state
var $scanButton = $('.openwebrx-squelch-auto');
$scanButton.css('animation-name', '');
$scanButton.removeClass('highlighted');
}
}
function toggleScanner() {