Skip to content

Commit 19e71c5

Browse files
martinpittmvollmer
authored andcommitted
FIXUP: Trigger scan only on details page
It's too expensive and not useful enough on the overview. OTOH, trigger a scan on each opening of a WiFi device details page, so that the information there is current and useful. This means that we the number of APs in the overview is less reliable, but that's fine -- after a while NM forgets them anyway. Curiously the tests (which check "3 networks" on the overview) are still fine -- apparently NM does a passive scan automatically on startup, or for a newly appearing device? #22884 (comment)
1 parent 6c0b3be commit 19e71c5

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

pkg/networkmanager/interfaces.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,18 +1204,7 @@ export function NetworkManagerModel() {
12041204
console.warn("request_scan: scan failed for", this.Interface + ":", error.toString());
12051205
});
12061206
}
1207-
},
1208-
1209-
exporters: [
1210-
function (obj) {
1211-
// Once we see any WiFi device, trigger one initial scan
1212-
if (obj.DeviceType === '802-11-wireless' && !priv(obj).wifi_scan_requested) {
1213-
utils.debug("triggering initial WiFi scan for", obj.Interface);
1214-
priv(obj).wifi_scan_requested = true;
1215-
obj.request_scan();
1216-
}
1217-
}
1218-
]
1207+
}
12191208
};
12201209

12211210
// The 'Interface' type does not correspond to any NetworkManager

pkg/networkmanager/network-interface.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import cockpit from "cockpit";
66
import React, { useContext, useEffect, useRef, useState } from "react";
7-
import { useEvent } from "hooks";
7+
import { useEvent, useInit } from "hooks";
88
import { Breadcrumb, BreadcrumbItem } from "@patternfly/react-core/dist/esm/components/Breadcrumb/index.js";
99
import { Button } from "@patternfly/react-core/dist/esm/components/Button/index.js";
1010
import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core/dist/esm/components/Card/index.js';
@@ -283,6 +283,14 @@ export const NetworkInterfacePage = ({
283283

284284
const Dialogs = useDialogs();
285285

286+
// Trigger (passive) scan on page load for wireless devices on page load
287+
useInit(() => {
288+
if (dev?.DeviceType === '802-11-wireless') {
289+
utils.debug("Requesting initial WiFi scan for", dev_name);
290+
dev.request_scan();
291+
}
292+
});
293+
286294
// WiFi scanning: re-enable button when APs change or after timeout
287295
useEffect(() => {
288296
if (isScanning) {

0 commit comments

Comments
 (0)