From fb3126bfdb840994f3968f2dbededcf4404fd6d6 Mon Sep 17 00:00:00 2001 From: Sasha Weiss Date: Tue, 30 Sep 2025 16:34:48 -0700 Subject: [PATCH] Add confirmation before downgrading paid -> free Backups --- .../ChooseBackupPlanViewController.swift | 37 ++++++++++++++++++- .../translations/en.lproj/Localizable.strings | 12 ++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Signal/Backups/ChooseBackupPlanViewController.swift b/Signal/Backups/ChooseBackupPlanViewController.swift index fff8b0d3de..503788010f 100644 --- a/Signal/Backups/ChooseBackupPlanViewController.swift +++ b/Signal/Backups/ChooseBackupPlanViewController.swift @@ -26,6 +26,7 @@ class ChooseBackupPlanViewController: HostingController { private let db: DB private let tsAccountManager: TSAccountManager + private let initialPlanSelection: PlanSelection? private let onConfirmPlanSelectionBlock: OnConfirmPlanSelectionBlock private let viewModel: ChooseBackupPlanViewModel @@ -43,6 +44,7 @@ class ChooseBackupPlanViewController: HostingController { self.db = db self.tsAccountManager = tsAccountManager + self.initialPlanSelection = initialPlanSelection self.onConfirmPlanSelectionBlock = onConfirmPlanSelectionBlock self.viewModel = ChooseBackupPlanViewModel( initialPlanSelection: initialPlanSelection, @@ -94,7 +96,30 @@ class ChooseBackupPlanViewController: HostingController { extension ChooseBackupPlanViewController: ChooseBackupPlanViewModel.ActionsDelegate { fileprivate func confirmSelection(_ planSelection: PlanSelection) { - onConfirmPlanSelectionBlock(self, planSelection) + switch (initialPlanSelection, planSelection) { + case (.free, .free), (.paid, .paid): + owsFail("Unexpectedly confirmed selection of initial plan! This should've been disallowed.") + case (nil, _), (.free, .paid): + onConfirmPlanSelectionBlock(self, planSelection) + case (.paid, .free): + OWSActionSheets.showConfirmationAlert( + title: OWSLocalizedString( + "CHOOSE_BACKUP_PLAN_DOWNGRADE_CONFIRMATION_ACTION_SHEET_TITLE", + comment: "Title for an action sheet confirming the user wants to downgrade their Backup plan." + ), + message: OWSLocalizedString( + "CHOOSE_BACKUP_PLAN_DOWNGRADE_CONFIRMATION_ACTION_SHEET_MESSAGE", + comment: "Message for an action sheet confirming the user wants to downgrade their Backup plan." + ), + proceedTitle: OWSLocalizedString( + "CHOOSE_BACKUP_PLAN_DOWNGRADE_CONFIRMATION_ACTION_SHEET_PROCEED_BUTTON", + comment: "Button for an action sheet confirming the user wants to downgrade their Backup plan." + ), + proceedAction: { [self] _ in + onConfirmPlanSelectionBlock(self, planSelection) + } + ) + } } } @@ -248,7 +273,15 @@ struct ChooseBackupPlanView: View { } label: { let text = switch viewModel.planSelection { case .free: - CommonStrings.continueButton + switch viewModel.initialPlanSelection { + case nil, .free: + CommonStrings.continueButton + case .paid: + OWSLocalizedString( + "CHOOSE_BACKUP_PLAN_DOWNGRADE_BUTTON_TEXT", + comment: "Text for a button that will downgrade the user from the paid Backup plan to the free one.", + ) + } case .paid: switch viewModel.storeKitAvailability { case .available(let paidPlanDisplayPrice): diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index d9623c2ff6..1b68af1c61 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1630,6 +1630,18 @@ /* A label indicating that a given Backup plan option is what the user has already enabled. */ "CHOOSE_BACKUP_PLAN_CURRENT_PLAN_LABEL" = "Current plan"; +/* Text for a button that will downgrade the user from the paid Backup plan to the free one. */ +"CHOOSE_BACKUP_PLAN_DOWNGRADE_BUTTON_TEXT" = "Change Plan"; + +/* Message for an action sheet confirming the user wants to downgrade their Backup plan. */ +"CHOOSE_BACKUP_PLAN_DOWNGRADE_CONFIRMATION_ACTION_SHEET_MESSAGE" = "All of your text messages and last 45 days of media will be included in your backup if you change your plan."; + +/* Button for an action sheet confirming the user wants to downgrade their Backup plan. */ +"CHOOSE_BACKUP_PLAN_DOWNGRADE_CONFIRMATION_ACTION_SHEET_PROCEED_BUTTON" = "Change Plan"; + +/* Title for an action sheet confirming the user wants to downgrade their Backup plan. */ +"CHOOSE_BACKUP_PLAN_DOWNGRADE_CONFIRMATION_ACTION_SHEET_TITLE" = "Downgrade to Free?"; + /* Subtitle for the free plan option, when choosing a Backup plan. */ "CHOOSE_BACKUP_PLAN_FREE_PLAN_SUBTITLE" = "Text + 45 days of media";