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 version = ""
|
||||||
@State private var dataSize: String?
|
@State private var dataSize: String?
|
||||||
|
@State private var dataSizeLoaded = false
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
@State private var helperUnavailable = false
|
@State private var helperUnavailable = false
|
||||||
@@ -38,6 +39,12 @@ public struct CoreView: View {
|
|||||||
FormTextItem("Version", version)
|
FormTextItem("Version", version)
|
||||||
if let dataSize {
|
if let dataSize {
|
||||||
FormTextItem("Data Size", dataSize)
|
FormTextItem("Data Size", dataSize)
|
||||||
|
} else if !dataSizeLoaded {
|
||||||
|
HStack {
|
||||||
|
Text("Data Size")
|
||||||
|
Spacer()
|
||||||
|
ProgressView()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
HStack {
|
HStack {
|
||||||
@@ -124,11 +131,6 @@ public struct CoreView: View {
|
|||||||
} else {
|
} else {
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
version = LibboxVersion()
|
version = LibboxVersion()
|
||||||
#if os(macOS)
|
|
||||||
if Variant.useSystemExtension {
|
|
||||||
helperUnavailable = HelperServiceManager.rootHelperStatus != .enabled
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
await loadSettingsBackground()
|
await loadSettingsBackground()
|
||||||
@@ -173,6 +175,7 @@ public struct CoreView: View {
|
|||||||
self.helperUnavailable = helperUnavailable
|
self.helperUnavailable = helperUnavailable
|
||||||
#endif
|
#endif
|
||||||
self.dataSize = dataSize
|
self.dataSize = dataSize
|
||||||
|
self.dataSizeLoaded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public struct AppView: View {
|
|||||||
@Environment(\.showMenuBarExtra) private var showMenuBarExtra
|
@Environment(\.showMenuBarExtra) private var showMenuBarExtra
|
||||||
@Environment(\.menuBarExtraSpeedMode) private var menuBarExtraSpeedMode
|
@Environment(\.menuBarExtraSpeedMode) private var menuBarExtraSpeedMode
|
||||||
@State private var menuBarExtraInBackground = false
|
@State private var menuBarExtraInBackground = false
|
||||||
|
@State private var helperStatusLoaded = false
|
||||||
@State private var rootHelperRegistrationStatus: SMAppService.Status = .notRegistered
|
@State private var rootHelperRegistrationStatus: SMAppService.Status = .notRegistered
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -108,7 +109,9 @@ public struct AppView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
if rootHelperRegistrationStatus == .enabled {
|
if !helperStatusLoaded {
|
||||||
|
ProgressView()
|
||||||
|
} else if rootHelperRegistrationStatus == .enabled {
|
||||||
FormButton {
|
FormButton {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
@@ -171,11 +174,14 @@ public struct AppView: View {
|
|||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
startAtLogin = SMAppService.mainApp.status == .enabled
|
startAtLogin = SMAppService.mainApp.status == .enabled
|
||||||
menuBarExtraInBackground = await SharedPreferences.menuBarExtraInBackground.get()
|
menuBarExtraInBackground = await SharedPreferences.menuBarExtraInBackground.get()
|
||||||
if Variant.useSystemExtension {
|
|
||||||
refreshHelperStatus()
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
isLoading = false
|
isLoading = false
|
||||||
|
#if os(macOS)
|
||||||
|
if Variant.useSystemExtension {
|
||||||
|
refreshHelperStatus()
|
||||||
|
helperStatusLoaded = true
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func currentLanguage() -> String? {
|
private static func currentLanguage() -> String? {
|
||||||
|
|||||||
Reference in New Issue
Block a user