From 0d1e24022786d1f4f15843f95215341e997cd354 Mon Sep 17 00:00:00 2001 From: Phuoc NTB Date: Wed, 1 Jul 2026 10:10:49 +0700 Subject: [PATCH] update macos wifi refresh and logout clear --- client/app.go | 18 ++++++++++++------ client/internal/winapi/wifi_darwin.m | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/client/app.go b/client/app.go index 29aa498..a642218 100644 --- a/client/app.go +++ b/client/app.go @@ -662,14 +662,20 @@ func (a *App) authStorageScanner() { // monitorLoop định kỳ 10s: check wifi, ping backend, cập nhật online/offline seconds và đồng bộ lên server func (a *App) monitorLoop() { - ticker := time.NewTicker(10 * time.Second) - defer ticker.Stop() - - a.runMonitorTick() - for { - <-ticker.C a.runMonitorTick() + + a.mu.Lock() + wifiEmpty := a.wifiSSID == "" || strings.Contains(a.wifiSSID, "Chưa cấp quyền") || strings.Contains(a.wifiSSID, "redacted") + expecting := a.expectingLogin + a.mu.Unlock() + + sleepInterval := 10 * time.Second + if wifiEmpty && !expecting { + sleepInterval = 2 * time.Second + } + + time.Sleep(sleepInterval) } } diff --git a/client/internal/winapi/wifi_darwin.m b/client/internal/winapi/wifi_darwin.m index 35e8e03..e9f8901 100644 --- a/client/internal/winapi/wifi_darwin.m +++ b/client/internal/winapi/wifi_darwin.m @@ -26,7 +26,7 @@ CWifiInfo GetCurrentWifiInfo() { info.bssid = NULL; @autoreleasepool { - CWWiFiClient *client = [CWWiFiClient sharedWiFiClient]; + CWWiFiClient *client = [[CWWiFiClient alloc] init]; if (client != nil) { CWInterface *interface = [client interface]; if (interface != nil) {