Revert async loadCurrentProfile()
Make action sync, but internally async (makeProfileReady). If not
doing so, UI on launch will not be able to show active profile
immediately. WelcomeView would appear for a moment.
Observe isReloadingCurrentProfile.
See 2b1efb8fec
This commit is contained in:
parent
1ef2b8c7a7
commit
2c2e794b00
|
@ -141,12 +141,10 @@ class AppContext {
|
|||
|
||||
if let activeProfileId = appManager.activeProfileId {
|
||||
profileManager.setActiveProfileId(activeProfileId)
|
||||
Task {
|
||||
do {
|
||||
try await profileManager.loadCurrentProfile(withId: activeProfileId)
|
||||
} catch {
|
||||
pp_log.warning("Unable to load active profile: \(error)")
|
||||
}
|
||||
do {
|
||||
try profileManager.loadCurrentProfile(withId: activeProfileId)
|
||||
} catch {
|
||||
pp_log.warning("Unable to load active profile: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,13 +158,11 @@ extension OrganizerView.ProfilesList {
|
|||
}
|
||||
|
||||
private func presentProfile(withId id: UUID) {
|
||||
Task {
|
||||
isPresentingProfile = true
|
||||
do {
|
||||
try await profileManager.loadCurrentProfile(withId: id)
|
||||
} catch {
|
||||
pp_log.error("Unable to load profile: \(error)")
|
||||
}
|
||||
isPresentingProfile = true
|
||||
do {
|
||||
try profileManager.loadCurrentProfile(withId: id)
|
||||
} catch {
|
||||
pp_log.error("Unable to load profile: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -212,12 +212,10 @@ extension ProfileView {
|
|||
return
|
||||
}
|
||||
if switchCurrentProfile {
|
||||
Task {
|
||||
do {
|
||||
try await profileManager.loadCurrentProfile(withId: copy.id)
|
||||
} catch {
|
||||
pp_log.warning("Unable to load profile duplicate: \(error)")
|
||||
}
|
||||
do {
|
||||
try profileManager.loadCurrentProfile(withId: copy.id)
|
||||
} catch {
|
||||
pp_log.warning("Unable to load profile duplicate: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ extension ProfileManager {
|
|||
// MARK: Observation
|
||||
|
||||
extension ProfileManager {
|
||||
public func loadCurrentProfile(withId id: UUID) async throws {
|
||||
public func loadCurrentProfile(withId id: UUID) throws {
|
||||
guard !isLoadingCurrentProfile else {
|
||||
pp_log.warning("Already loading another profile")
|
||||
return
|
||||
|
@ -272,13 +272,14 @@ extension ProfileManager {
|
|||
let result = try profileEx(withId: id)
|
||||
pp_log.info("Current profile: \(result.profile.logDescription)")
|
||||
|
||||
currentProfile.value = result.profile
|
||||
if result.isReady {
|
||||
currentProfile.value = result.profile
|
||||
isLoadingCurrentProfile = false
|
||||
} else {
|
||||
try await makeProfileReady(result.profile)
|
||||
currentProfile.value = result.profile
|
||||
isLoadingCurrentProfile = false
|
||||
Task {
|
||||
try await makeProfileReady(result.profile)
|
||||
isLoadingCurrentProfile = false
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
currentProfile.value = .placeholder
|
||||
|
|
Loading…
Reference in New Issue