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:
@@ -19,6 +19,7 @@ public struct CoreView: View {
|
||||
|
||||
@State private var version = ""
|
||||
@State private var dataSize: String?
|
||||
@State private var dataSizeLoaded = false
|
||||
|
||||
#if os(macOS)
|
||||
@State private var helperUnavailable = false
|
||||
@@ -38,6 +39,12 @@ public struct CoreView: View {
|
||||
FormTextItem("Version", version)
|
||||
if let dataSize {
|
||||
FormTextItem("Data Size", dataSize)
|
||||
} else if !dataSizeLoaded {
|
||||
HStack {
|
||||
Text("Data Size")
|
||||
Spacer()
|
||||
ProgressView()
|
||||
}
|
||||
} else {
|
||||
#if os(macOS)
|
||||
HStack {
|
||||
@@ -124,11 +131,6 @@ public struct CoreView: View {
|
||||
} else {
|
||||
await MainActor.run {
|
||||
version = LibboxVersion()
|
||||
#if os(macOS)
|
||||
if Variant.useSystemExtension {
|
||||
helperUnavailable = HelperServiceManager.rootHelperStatus != .enabled
|
||||
}
|
||||
#endif
|
||||
isLoading = false
|
||||
}
|
||||
await loadSettingsBackground()
|
||||
@@ -173,6 +175,7 @@ public struct CoreView: View {
|
||||
self.helperUnavailable = helperUnavailable
|
||||
#endif
|
||||
self.dataSize = dataSize
|
||||
self.dataSizeLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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? {
|
||||
|
||||
Reference in New Issue
Block a user