Skip to content

Commit f8c09d3

Browse files
committed
Enhance scan ETA display logic to reload data for newly discovered devices after scanning finishes
1 parent d8d0904 commit f8c09d3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

front/devices.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ function hasEnabledDeviceScanners() {
624624
// Update the title-bar ETA subtitle and the DataTables empty-state message.
625625
// Called on every nax:scanEtaUpdate; the inner ticker keeps the title bar live between events.
626626
function updateScanEtaDisplay(nextScanTime, currentState) {
627+
// Detect scan-finished transition BEFORE updating _currentStateAnchor.
628+
// justFinishedScanning is true only when the backend transitions scanning → idle.
629+
var justFinishedScanning = (currentState === 'Process: Idle') && isScanningState(_currentStateAnchor);
630+
627631
// Prefer the backend-computed values; keep previous anchors if not yet received.
628632
_nextScanTimeAnchor = nextScanTime || _nextScanTimeAnchor;
629633
_currentStateAnchor = currentState || _currentStateAnchor;
@@ -670,6 +674,13 @@ function tickTitleBar() {
670674
// Patch the visible cell text without triggering a server-side AJAX reload.
671675
$('#tableDevices tbody .dataTables_empty').html(newEmptyMsg);
672676
}
677+
678+
// When scanning just finished and the table is still empty, reload data so
679+
// newly discovered devices appear automatically. Skip reload if there are
680+
// already rows — no need to disturb the user's current view.
681+
if (justFinishedScanning && dt.page.info().recordsTotal === 0) {
682+
dt.ajax.reload(null, false); // false = keep current page position
683+
}
673684
}
674685

675686
tickTitleBar();

0 commit comments

Comments
 (0)