Skip to content

Commit 1190434

Browse files
committed
Update banner status on each run (for testing)
1 parent cfabb43 commit 1190434

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrderListViewModel.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@ final class OrderListViewModel {
176176
bindTopBannerState()
177177

178178
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.IPPInAppFeedbackBanner) {
179+
syncIPPBannerVisibility()
179180
loadOrdersBannerVisibility()
180-
loadIPPFeedbackBannerVisibility()
181-
fetchIPPTransactions()
182181
} else {
183182
loadOrdersBannerVisibility()
184183
}
@@ -220,17 +219,28 @@ final class OrderListViewModel {
220219
stores.dispatch(action)
221220
}
222221

222+
// This is a temporary method in order to update the IPP feedback status to `.pending`, and
223+
// then load feedback visibility. We need to reset the banner status on UserDefaults for
224+
// the banner to appear again for testing purposes.
225+
private func syncIPPBannerVisibility() {
226+
let action = AppSettingsAction.updateFeedbackStatus(type: .IPP, status: .pending) { _ in
227+
self.loadIPPFeedbackBannerVisibility()
228+
self.fetchIPPTransactions()
229+
}
230+
stores.dispatch(action)
231+
}
232+
223233
private func loadIPPFeedbackBannerVisibility() {
224234
let action = AppSettingsAction.loadFeedbackVisibility(type: .IPP) { [weak self] result in
225235
switch result {
226236
case .success(let visible):
227-
self?.hideIPPFeedbackBanner = visible
237+
self?.hideIPPFeedbackBanner = !visible
228238
case .failure(let error):
229239
self?.hideIPPFeedbackBanner = true
230240
ServiceLocator.crashLogging.logError(error)
231241
}
232242
}
233-
stores.dispatch(action)
243+
self.stores.dispatch(action)
234244
}
235245

236246
@objc private func handleAppDeactivation() {

0 commit comments

Comments
 (0)