diff --git a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift index 34bdd80d..bcec14be 100644 --- a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift +++ b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift @@ -270,35 +270,25 @@ extension ProfileManager { pp_log.debug("Profile \(id) is already current profile") return } - currentProfile.isLoading = true if isExistingProfile(withId: currentProfile.value.id) { pp_log.info("Committing changes of former current profile \(currentProfile.value.logDescription)") 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 - if result.isReady { + } else { + currentProfile.isLoading = true + Task { + try await makeProfileReady(result.profile) + currentProfile.value = result.profile 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 { isExistingProfile(withId: currentProfile.value.id) }