From e58726d0afae2d0bab717dd269d69f62aa2378fe Mon Sep 17 00:00:00 2001 From: Davide Date: Sun, 17 Nov 2024 18:21:37 +0100 Subject: [PATCH] Do not discard migrated profiles in TestFlight (#886) Users would lose those profiles on downgrade to v2. --- .../Views/Migration/MigrateView.swift | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Passepartout/Library/Sources/AppUIMain/Views/Migration/MigrateView.swift b/Passepartout/Library/Sources/AppUIMain/Views/Migration/MigrateView.swift index 020c77718..bde47b9ac 100644 --- a/Passepartout/Library/Sources/AppUIMain/Views/Migration/MigrateView.swift +++ b/Passepartout/Library/Sources/AppUIMain/Views/Migration/MigrateView.swift @@ -40,6 +40,9 @@ struct MigrateView: View { @EnvironmentObject private var migrationManager: MigrationManager + @EnvironmentObject + private var iapManager: IAPManager + @Environment(\.dismiss) private var dismiss @@ -187,12 +190,18 @@ private extension MigrateView { model.statuses[$0.id] == .done } pp_log(.App.migration, .notice, "Migrated \(migrated.count) profiles") - do { - try await migrationManager.deleteMigratableProfiles(withIds: Set(migrated.map(\.id))) - pp_log(.App.migration, .notice, "Discarded \(migrated.count) migrated profiles from old store") - } catch { - pp_log(.App.migration, .error, "Unable to discard migrated profiles: \(error)") + + if !iapManager.isRestricted { + do { + try await migrationManager.deleteMigratableProfiles(withIds: Set(migrated.map(\.id))) + pp_log(.App.migration, .notice, "Discarded \(migrated.count) migrated profiles from old store") + } catch { + pp_log(.App.migration, .error, "Unable to discard migrated profiles: \(error)") + } + } else { + pp_log(.App.migration, .notice, "Restricted build, do not discard migrated profiles") } + model.step = .migrated(migrated) } catch { pp_log(.App.migration, .error, "Unable to migrate profiles: \(error)")