Defer XPC-dependent loading in macOS standalone settings views

Show non-XPC content immediately in App Settings and Core Settings,
loading Helper Service status and Data Size in a second phase to
avoid blocking the entire form and eliminate the red "Unavailable" flash.
This commit is contained in:
世界
2026-03-05 23:04:46 +08:00
parent 16800708dd
commit a1ac77e08f
2 changed files with 18 additions and 9 deletions
@@ -29,6 +29,7 @@ public struct AppView: View {
@Environment(\.showMenuBarExtra) private var showMenuBarExtra
@Environment(\.menuBarExtraSpeedMode) private var menuBarExtraSpeedMode
@State private var menuBarExtraInBackground = false
@State private var helperStatusLoaded = false
@State private var rootHelperRegistrationStatus: SMAppService.Status = .notRegistered
#endif
@@ -108,7 +109,9 @@ public struct AppView: View {
}
Section {
if rootHelperRegistrationStatus == .enabled {
if !helperStatusLoaded {
ProgressView()
} else if rootHelperRegistrationStatus == .enabled {
FormButton {
Task {
do {
@@ -171,11 +174,14 @@ public struct AppView: View {
#if os(macOS)
startAtLogin = SMAppService.mainApp.status == .enabled
menuBarExtraInBackground = await SharedPreferences.menuBarExtraInBackground.get()
if Variant.useSystemExtension {
refreshHelperStatus()
}
#endif
isLoading = false
#if os(macOS)
if Variant.useSystemExtension {
refreshHelperStatus()
helperStatusLoaded = true
}
#endif
}
private static func currentLanguage() -> String? {