-
Notifications
You must be signed in to change notification settings - Fork 121
[IPPInAppFeedback] Banner dismiss logic #8657
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 18 commits
a92bddd
8de3516
cf03baf
232f4bc
bcb327e
398874b
c7356c7
2aa3298
7b68aa7
523fe0a
70d9cbd
909bea5
f8a2586
80a1b1b
2177584
d6b1d0a
cdc5089
f294478
d5e02a2
6a53fd6
9884f22
914d62c
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 |
|---|---|---|
|
|
@@ -351,6 +351,34 @@ final class OrderListViewModel { | |
| } | ||
| } | ||
|
|
||
| // MARK: - In-Person Payments Feedback Banner | ||
|
|
||
| extension OrderListViewModel { | ||
| func dismissIPPFeedbackBanner(remindAfterDays: Int?) { | ||
| // Updates the IPP feedback banner status as dismissed | ||
| let updateFeedbackStatus = AppSettingsAction.updateFeedbackStatus(type: .IPP, status: .dismissed) { [weak self] _ in | ||
| self?.hideIPPFeedbackBanner = true | ||
| } | ||
| stores.dispatch(updateFeedbackStatus) | ||
|
|
||
| // Updates the IPP feedback banner status to be reminded later, or never | ||
| let updateBannerVisibility = AppSettingsAction.setFeatureAnnouncementDismissed( | ||
| campaign: .IPP, | ||
| remindAfterDays: remindAfterDays, | ||
| onCompletion: nil | ||
| ) | ||
| stores.dispatch(updateBannerVisibility) | ||
| } | ||
|
|
||
| func remindMeLaterTapped() { | ||
|
||
| dismissIPPFeedbackBanner(remindAfterDays: Constants.remindIPPBannerDismissalAfterDays) | ||
| } | ||
|
|
||
| func dontShowAgainTapped() { | ||
| dismissIPPFeedbackBanner(remindAfterDays: nil) | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Remote Notifications Observation | ||
|
|
||
| private extension OrderListViewModel { | ||
|
|
@@ -466,5 +494,6 @@ private extension OrderListViewModel { | |
| static let paymentMethodTitle = "WooCommerce In-Person Payments" | ||
| static let receiptURLKey = "receipt_url" | ||
| static let numberOfTransactions = 10 | ||
| static let remindIPPBannerDismissalAfterDays = 7 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -841,14 +841,31 @@ final class AppSettingsStoreTests: XCTestCase { | |||||
|
|
||||||
| extension AppSettingsStoreTests { | ||||||
|
|
||||||
| func test_setFeatureAnnouncementDismissed_for_campaign_when_remindAfterDays_is_nil_then_does_not_store_current_date() throws { | ||||||
| // Given | ||||||
| try fileStorage?.deleteFile(at: expectedGeneralStoreSettingsFileURL) | ||||||
| // When | ||||||
iamgabrielma marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| let action = AppSettingsAction.setFeatureAnnouncementDismissed(campaign: .upsellCardReaders, remindAfterDays: nil, onCompletion: nil) | ||||||
| subject?.onAction(action) | ||||||
|
|
||||||
| // Then | ||||||
| var savedSettings: GeneralAppSettings? = try XCTUnwrap(fileStorage?.data(for: expectedGeneralAppSettingsFileURL)) | ||||||
| XCTAssertNil(savedSettings) | ||||||
| guard let savedSettings else { | ||||||
| return | ||||||
| } | ||||||
| var savedDate: Date? = try XCTUnwrap( savedSettings.featureAnnouncementCampaignSettings[.upsellCardReaders]?.dismissedDate) | ||||||
| XCTAssertNil(savedDate) | ||||||
| } | ||||||
|
|
||||||
| func test_setFeatureAnnouncementDismissed_for_campaign_stores_current_date() throws { | ||||||
| // Given | ||||||
| let currentTime = Date() | ||||||
|
|
||||||
| try fileStorage?.deleteFile(at: expectedGeneralStoreSettingsFileURL) | ||||||
|
|
||||||
| // When | ||||||
| let action = AppSettingsAction.setFeatureAnnouncementDismissed(campaign: .upsellCardReaders, remindLater: false, onCompletion: nil) | ||||||
| let action = AppSettingsAction.setFeatureAnnouncementDismissed(campaign: .upsellCardReaders, remindAfterDays: 0, onCompletion: nil) | ||||||
| subject?.onAction(action) | ||||||
|
|
||||||
| // Then | ||||||
|
|
@@ -859,14 +876,15 @@ extension AppSettingsStoreTests { | |||||
| XCTAssert(Calendar.current.isDate(actualDismissDate, inSameDayAs: currentTime)) | ||||||
| } | ||||||
|
|
||||||
| func test_setFeatureAnnouncementDismissed_with_remindLater_true_stores_reminder_date_in_two_weeks() throws { | ||||||
| func test_setFeatureAnnouncementDismissed_with_remindAfterDays_two_weeks_stores_reminder_date_in_two_weeks() throws { | ||||||
|
||||||
| func test_setFeatureAnnouncementDismissed_with_remindAfterDays_two_weeks_stores_reminder_date_in_two_weeks() throws { | |
| func test_setFeatureAnnouncementDismissed_when_remindAfterDays_two_weeks_then_stores_reminder_date_in_two_weeks() throws { |
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.
test_setFeatureAnnouncementDismissed_when_remindAfterDays_is_two_weeks_then_stores_reminder_date_is_two_weeks()
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.
Nice change moving the logic to the view model! However, the
remindAfterDayslogic can be contained in the view model; the view doesn't need to know about when are we going to show it again. With that, we can remove this parameterremindAfterDaysfrom this function.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.
Changed here the remaining use of
remindAfterDays: d5e02a2 to a new method, so this is entirely contained in the view model now 👍