Guard async init against stale enable/disable cycles with epoch counter
This commit is contained in:
parent
d0ad901aab
commit
956f4b5916
1 changed files with 3 additions and 0 deletions
|
|
@ -120,12 +120,15 @@ export default class WifiSignalPlusExtension extends Extension {
|
||||||
private nearbyUpdatePending = false;
|
private nearbyUpdatePending = false;
|
||||||
private currentConnectedBssid: string | undefined;
|
private currentConnectedBssid: string | undefined;
|
||||||
private isMenuOpen = false;
|
private isMenuOpen = false;
|
||||||
|
private enableEpoch = 0;
|
||||||
|
|
||||||
enable(): void {
|
enable(): void {
|
||||||
|
const epoch = ++this.enableEpoch;
|
||||||
this.wifiService = new WifiInfoService();
|
this.wifiService = new WifiInfoService();
|
||||||
this.wifiService
|
this.wifiService
|
||||||
.init()
|
.init()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
if (epoch !== this.enableEpoch) return;
|
||||||
if (!this.wifiService) return;
|
if (!this.wifiService) return;
|
||||||
this.wifiService.requestScan();
|
this.wifiService.requestScan();
|
||||||
this.wifiService.watchDeviceSignals(() => {
|
this.wifiService.watchDeviceSignals(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue