Serialize active profile immediately
Otherwise: - Switch from former active profile A to B - Connect to now active profile B - Kill app - Reopen app - App shows connected to profile A Because active profile was not saved immediately on switch. Unnecessary now to also save it on background persist().
This commit is contained in:
parent
7095791428
commit
322bdf2993
|
@ -84,7 +84,6 @@ extension OrganizerView {
|
|||
}
|
||||
|
||||
private func persist() {
|
||||
appManager.activeProfileId = profileManager.activeProfileId
|
||||
profileManager.persist()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import PassepartoutCore
|
|||
|
||||
extension ProfileView {
|
||||
struct VPNSection: View {
|
||||
@ObservedObject private var appManager: AppManager
|
||||
|
||||
@ObservedObject private var profileManager: ProfileManager
|
||||
|
||||
@ObservedObject private var providerManager: ProviderManager
|
||||
|
@ -51,6 +53,7 @@ extension ProfileView {
|
|||
}
|
||||
|
||||
init(currentProfile: ObservableProfile, isLoaded: Bool) {
|
||||
appManager = .shared
|
||||
profileManager = .shared
|
||||
providerManager = .shared
|
||||
vpnManager = .shared
|
||||
|
@ -109,6 +112,9 @@ extension ProfileView {
|
|||
Button(L10n.Profile.Items.UseProfile.caption) {
|
||||
withAnimation {
|
||||
profileManager.activateCurrentProfile()
|
||||
|
||||
// IMPORTANT: save immediately to keep in sync with VPN status
|
||||
appManager.activeProfileId = profileManager.activeProfileId
|
||||
}
|
||||
Task {
|
||||
await vpnManager.disable()
|
||||
|
|
|
@ -153,6 +153,7 @@ extension AppManager: AppPreferences {
|
|||
}
|
||||
set {
|
||||
defaults.set(newValue?.uuidString, forKey: DefaultKey.activeProfileId.rawValue)
|
||||
defaults.synchronize()
|
||||
objectWillChange.send()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue