From 10537c5a29f1165a2910e9336bfb0e11a7874c6b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 23 Apr 2022 10:21:27 +0200 Subject: [PATCH] Fix active profile not always cleared on deletion Was only cleared if deleted profile was current profile. --- .../PassepartoutProfiles/Managers/ProfileManager.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift index 6ef8f6d5..88680136 100644 --- a/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift +++ b/PassepartoutCore/Sources/PassepartoutProfiles/Managers/ProfileManager.swift @@ -335,10 +335,6 @@ extension ProfileManager { // IMPORTANT: invalidate current profile if deleted if !currentProfile.value.isPlaceholder && !newHeaders.keys.contains(currentProfile.value.id) { pp_log.info("\tCurrent profile deleted, invalidating...") - if isCurrentProfileActive() { - pp_log.info("\tCurrent profile was also active, deactivating...") - activeProfileId = nil - } currentProfile.value = .placeholder } @@ -348,6 +344,11 @@ extension ProfileManager { currentProfile.value = newProfile } + if let activeProfileId = activeProfileId, !newHeaders.keys.contains(activeProfileId) { + pp_log.info("\tActive profile was deleted") + self.activeProfileId = nil + } + // IMPORTANT: defer task to avoid recursive saves // FIXME: Core Data, not sure about this workaround Task {