-
Notifications
You must be signed in to change notification settings - Fork 121
[IPPInAppFeedback] Orders screen banner placement #8640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
67a0786
cf2f861
c43dce1
2055cfb
48a7f92
19cac93
038b736
5f96815
83835c4
ff7a3ee
d96ba4e
b20f591
94e63d5
f0c1d60
5cbd991
cfabb43
1190434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,6 +131,11 @@ final class OrderListViewModel { | |
| /// | ||
| @Published var hideOrdersBanners: Bool = true | ||
|
|
||
| /// If true, no IPP feedback banner will be shown as the user has told us that they are not interested in this information. | ||
| /// It is persisted through app sessions. | ||
| /// | ||
| @Published var hideIPPFeedbackBanner: Bool = false | ||
|
|
||
| init(siteID: Int64, | ||
| stores: StoresManager = ServiceLocator.stores, | ||
| storageManager: StorageManagerType = ServiceLocator.storageManager, | ||
|
|
@@ -143,6 +148,12 @@ final class OrderListViewModel { | |
| self.pushNotificationsManager = pushNotificationsManager | ||
| self.notificationCenter = notificationCenter | ||
| self.filters = filters | ||
|
|
||
| if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.IPPInAppFeedbackBanner) { | ||
| // TODO: Remove. Temporarily set to false so we can debug the IPPFeedback banner easily. | ||
| hideOrdersBanners = false | ||
|
||
| topBanner = .IPPFeedback | ||
| } | ||
| } | ||
|
|
||
| deinit { | ||
|
|
@@ -165,10 +176,12 @@ final class OrderListViewModel { | |
|
|
||
| observeForegroundRemoteNotifications() | ||
| bindTopBannerState() | ||
| loadOrdersBannerVisibility() | ||
|
|
||
| if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.IPPInAppFeedbackBanner) { | ||
| loadIPPFeedbackBannerVisibility() | ||
|
||
| fetchIPPTransactions() | ||
| } else { | ||
| loadOrdersBannerVisibility() | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -185,6 +198,15 @@ final class OrderListViewModel { | |
| stores.dispatch(action) | ||
| } | ||
|
|
||
| func dismissIPPFeedbackBanner() { | ||
| print("dismiss tapped") | ||
|
||
| let action = AppSettingsAction.updateFeedbackStatus(type: .IPPFeedback, status: .dismissed, onCompletion: { _ in | ||
| self.hideIPPFeedbackBanner = true | ||
| print("hideIPPFeedbackBanner? \(self.hideIPPFeedbackBanner)") | ||
| }) | ||
| stores.dispatch(action) | ||
| } | ||
|
|
||
| /// Starts the snapshotsProvider, logging any errors. | ||
| private func startReceivingSnapshots() { | ||
| do { | ||
|
|
@@ -208,6 +230,19 @@ final class OrderListViewModel { | |
| stores.dispatch(action) | ||
| } | ||
|
|
||
| private func loadIPPFeedbackBannerVisibility() { | ||
| let action = AppSettingsAction.loadFeedbackVisibility(type: .IPPFeedback) { [weak self] result in | ||
| switch result { | ||
| case .success(let visible): | ||
| self?.hideIPPFeedbackBanner = !visible | ||
| case .failure(let error): | ||
| self?.hideIPPFeedbackBanner = true | ||
| ServiceLocator.crashLogging.logError(error) | ||
| } | ||
| } | ||
| stores.dispatch(action) | ||
| } | ||
|
|
||
| @objc private func handleAppDeactivation() { | ||
| isAppActive = false | ||
| } | ||
|
|
@@ -376,7 +411,11 @@ extension OrderListViewModel { | |
| return .none | ||
| } | ||
|
|
||
| return .orderCreation | ||
| if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.IPPInAppFeedbackBanner) { | ||
| return .IPPFeedback | ||
| } else { | ||
| return .orderCreation | ||
| } | ||
| } | ||
| .assign(to: &$topBanner) | ||
| } | ||
|
|
@@ -419,6 +458,7 @@ extension OrderListViewModel { | |
| enum TopBanner { | ||
| case error | ||
| case orderCreation | ||
| case IPPFeedback | ||
| case none | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing here, if the enum type name already contains "Feedback", I think we can omit it here:
case IPP, as in the case of theordersCreationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed on 83835c4