mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-14 23:26:39 +03:00
Fix live detector empty state (#190)
* Fix live detector empty state * Fix live detector stale scan results
This commit is contained in:
@@ -6088,6 +6088,10 @@ void main() {
|
||||
let steerFocusRecoverTimer = null;
|
||||
const STEER_PAGE_FOCUS_PAUSE_MS = 500;
|
||||
let detectActive = false;
|
||||
let detectScanSeq = 0;
|
||||
let activeDetectScanId = null;
|
||||
let pendingDetectScanId = null;
|
||||
const DETECT_EMPTY_MESSAGE = 'No detector issues found.';
|
||||
const PICK_PREFS_KEY = 'impeccable-live-pick';
|
||||
const INTERACTION_PREFS_KEY = 'impeccable-live-interaction';
|
||||
const PLACEHOLDER_DEFAULT_HEIGHT = 80;
|
||||
@@ -7601,6 +7605,17 @@ void main() {
|
||||
let detectReady = false; // true once detect script posts 'impeccable-ready'
|
||||
let detectPendingScan = false; // scan requested before script was ready
|
||||
|
||||
function requestDetectScan() {
|
||||
const scanId = String(++detectScanSeq);
|
||||
activeDetectScanId = scanId;
|
||||
pendingDetectScanId = scanId;
|
||||
window.postMessage({
|
||||
source: 'impeccable-command',
|
||||
action: 'scan',
|
||||
config: { scanId },
|
||||
}, '*');
|
||||
}
|
||||
|
||||
function toggleDetect() {
|
||||
if (pendingApplyInFlight) { showManualApplyBusyToast(); return; }
|
||||
detectActive = !detectActive;
|
||||
@@ -7611,12 +7626,14 @@ void main() {
|
||||
detectPendingScan = true;
|
||||
loadDetectScript();
|
||||
} else if (detectReady) {
|
||||
window.postMessage({ source: 'impeccable-command', action: 'scan' }, '*');
|
||||
requestDetectScan();
|
||||
} else {
|
||||
detectPendingScan = true;
|
||||
}
|
||||
} else {
|
||||
window.postMessage({ source: 'impeccable-command', action: 'remove' }, '*');
|
||||
activeDetectScanId = null;
|
||||
pendingDetectScanId = null;
|
||||
detectCount = 0;
|
||||
updateGlobalBarState();
|
||||
}
|
||||
@@ -7686,12 +7703,18 @@ void main() {
|
||||
detectReady = true;
|
||||
if (detectPendingScan && detectActive) {
|
||||
detectPendingScan = false;
|
||||
window.postMessage({ source: 'impeccable-command', action: 'scan' }, '*');
|
||||
requestDetectScan();
|
||||
}
|
||||
}
|
||||
// Scan results arrived
|
||||
if (e.data.source === 'impeccable-results') {
|
||||
if (!detectActive) return;
|
||||
if (activeDetectScanId && e.data.scanId !== activeDetectScanId) return;
|
||||
detectCount = e.data.count || 0;
|
||||
if (detectActive && pendingDetectScanId && detectCount === 0) {
|
||||
showToast(DETECT_EMPTY_MESSAGE, 3200);
|
||||
}
|
||||
pendingDetectScanId = null;
|
||||
updateGlobalBarState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user