Skip to content

Commit

Permalink
Merge pull request #11269 from woocommerce/issue/fix-connectivity-too…
Browse files Browse the repository at this point in the history
…l-issues

[Better Errors] Fix troubleshooting banner visibility control
  • Loading branch information
ThomazFB authored Apr 9, 2024
2 parents 81cf865 + df7315a commit 26f1f38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,12 @@ class OrderListFragment :
show = show,
title = getString(R.string.orderlist_timeout_error_title),
message = getString(R.string.orderlist_timeout_error_message),
supportContactClick = { openSupportRequestScreen() },
supportContactClick = {
viewModel.changeTroubleshootingBannerVisibility(show = false)
openSupportRequestScreen()
},
troubleshootingClick = {
viewModel.changeTroubleshootingBannerVisibility(show = false)
viewModel.trackConnectivityTroubleshootClicked()
openConnectivityTool()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class OrderListViewModel @Inject constructor(
get() {
val simplePaymentsAndOrderFeedbackDismissed =
simplePaymentsAndOrderCreationFeedbackState == FeatureFeedbackSettings.FeedbackState.DISMISSED
return !simplePaymentsAndOrderFeedbackDismissed
val isTroubleshootingBannerVisible = viewState.shouldDisplayTroubleshootingBanner
return !simplePaymentsAndOrderFeedbackDismissed && !isTroubleshootingBannerVisible
}

init {
Expand Down Expand Up @@ -256,6 +257,13 @@ class OrderListViewModel @Inject constructor(
activatePagedListWrapper(pagedListWrapper, isFirstInit = true)
}

fun changeTroubleshootingBannerVisibility(show: Boolean) {
viewState = viewState.copy(
shouldDisplayTroubleshootingBanner = show,
isSimplePaymentsAndOrderCreationFeedbackVisible = !show
)
}

/**
* Removes the `#` from the start of the search keyword, if present.
*
Expand Down Expand Up @@ -449,9 +457,7 @@ class OrderListViewModel @Inject constructor(
triggerEvent(RetryLoadingOrders)
}

else -> viewState = viewState.copy(
shouldDisplayTroubleshootingBanner = true
)
else -> changeTroubleshootingBannerVisibility(show = true)
}
noTimeoutHappened = false
}
Expand Down

0 comments on commit 26f1f38

Please sign in to comment.