Skip to content

Commit ff49b0f

Browse files
committed
Dismiss banner after purchase
1 parent 8601108 commit ff49b0f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Cryptomator/MainCoordinator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ extension MainCoordinator: StoreObserverDelegate {
123123
switch transaction {
124124
case .fullVersion, .yearlySubscription:
125125
showFullVersionAlert()
126+
// Temporarily added for December 2024 Sale
127+
NotificationCenter.default.post(name: .dismissBannerNotification, object: nil)
126128
case let .freeTrial(expiresOn):
127129
showTrialAlert(expirationDate: expiresOn)
128130
case .unknown:

Cryptomator/Purchase/PurchaseCoordinator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class PurchaseCoordinator: Coordinator {
5151
PurchaseAlert.showForFullVersion(title: LocalizedString.getValue("purchase.unlockedFullVersion.title"), on: navigationController).then {
5252
self.unlockedPro()
5353
}
54+
// Temporarily added for December 2024 Sale
55+
NotificationCenter.default.post(name: .dismissBannerNotification, object: nil)
5456
}
5557

5658
func handleRestoreResult(_ result: RestoreTransactionsResult) {

Cryptomator/VaultList/VaultListViewController.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
1717
weak var coordinator: MainCoordinator?
1818

1919
private let viewModel: VaultListViewModelProtocol
20-
private var observer: NSObjectProtocol?
20+
private var willEnterForegroundObserver: NSObjectProtocol?
2121
@Dependency(\.fullVersionChecker) private var fullVersionChecker
2222
@Dependency(\.cryptomatorSettings) private var cryptomatorSettings
2323

2424
#if !ALWAYS_PREMIUM
2525
private var bannerView: UIView?
26+
private var fullVersionPurchasedObserver: NSObjectProtocol?
2627
#endif
2728

2829
init(with viewModel: VaultListViewModelProtocol) {
@@ -49,13 +50,16 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
4950
let addNewVaulButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addNewVault))
5051
navigationItem.rightBarButtonItem = addNewVaulButton
5152

52-
observer = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { [weak self] _ in
53+
willEnterForegroundObserver = NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: .main) { [weak self] _ in
5354
self?.viewModel.refreshVaultLockStates().catch { error in
5455
DDLogError("Refresh vault lock states failed with error: \(error)")
5556
}
5657
}
5758

5859
#if !ALWAYS_PREMIUM
60+
fullVersionPurchasedObserver = NotificationCenter.default.addObserver(forName: .dismissBannerNotification, object: nil, queue: .main) { [weak self] _ in
61+
self?.dismissBanner()
62+
}
5963
checkAndShowBanner()
6064
#endif
6165
}
@@ -204,3 +208,7 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
204208
}
205209
#endif
206210
}
211+
212+
extension Notification.Name {
213+
static let dismissBannerNotification = Notification.Name("DismissBannerNotification")
214+
}

0 commit comments

Comments
 (0)