Guard async init against stale enable/disable cycles with epoch counter

This commit is contained in:
Jalil Arfaoui 2026-02-27 00:38:15 +01:00
parent d0ad901aab
commit 956f4b5916

View file

@ -120,12 +120,15 @@ export default class WifiSignalPlusExtension extends Extension {
private nearbyUpdatePending = false;
private currentConnectedBssid: string | undefined;
private isMenuOpen = false;
private enableEpoch = 0;
enable(): void {
const epoch = ++this.enableEpoch;
this.wifiService = new WifiInfoService();
this.wifiService
.init()
.then(() => {
if (epoch !== this.enableEpoch) return;
if (!this.wifiService) return;
this.wifiService.requestScan();
this.wifiService.watchDeviceSignals(() => {