Only tweak .isLoading if profile is not ready
Result is sync and immediate otherwise.
This commit is contained in:
parent
d3bd41b251
commit
20be153b1a
|
@ -270,35 +270,25 @@ extension ProfileManager {
|
||||||
pp_log.debug("Profile \(id) is already current profile")
|
pp_log.debug("Profile \(id) is already current profile")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
currentProfile.isLoading = true
|
|
||||||
if isExistingProfile(withId: currentProfile.value.id) {
|
if isExistingProfile(withId: currentProfile.value.id) {
|
||||||
pp_log.info("Committing changes of former current profile \(currentProfile.value.logDescription)")
|
pp_log.info("Committing changes of former current profile \(currentProfile.value.logDescription)")
|
||||||
saveCurrentProfile()
|
saveCurrentProfile()
|
||||||
}
|
}
|
||||||
do {
|
|
||||||
let result = try profileEx(withId: id)
|
|
||||||
pp_log.info("Current profile: \(result.profile.logDescription)")
|
|
||||||
|
|
||||||
|
let result = try profileEx(withId: id)
|
||||||
|
pp_log.info("Current profile: \(result.profile.logDescription)")
|
||||||
|
if result.isReady {
|
||||||
currentProfile.value = result.profile
|
currentProfile.value = result.profile
|
||||||
if result.isReady {
|
} else {
|
||||||
|
currentProfile.isLoading = true
|
||||||
|
Task {
|
||||||
|
try await makeProfileReady(result.profile)
|
||||||
|
currentProfile.value = result.profile
|
||||||
currentProfile.isLoading = false
|
currentProfile.isLoading = false
|
||||||
} else {
|
|
||||||
Task {
|
|
||||||
try await makeProfileReady(result.profile)
|
|
||||||
currentProfile.isLoading = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
currentProfile.value = .placeholder
|
|
||||||
currentProfile.isLoading = false
|
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isCurrentProfileLoading() -> Bool {
|
|
||||||
currentProfile.isLoading
|
|
||||||
}
|
|
||||||
|
|
||||||
public func isCurrentProfileExisting() -> Bool {
|
public func isCurrentProfileExisting() -> Bool {
|
||||||
isExistingProfile(withId: currentProfile.value.id)
|
isExistingProfile(withId: currentProfile.value.id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue