-
Notifications
You must be signed in to change notification settings - Fork 136
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
[Woo POS] Cannot reconnect to Reader after turning internet off and on #12569
Conversation
…ct to card reader.
…ernet while trying to connect card reader.
…re is no internet.
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #12569 +/- ##
=========================================
Coverage 40.61% 40.61%
- Complexity 5680 5681 +1
=========================================
Files 1228 1229 +1
Lines 69103 69122 +19
Branches 9572 9574 +2
=========================================
+ Hits 28064 28073 +9
- Misses 38456 38466 +10
Partials 2583 2583 ☔ View full report in Codecov by Sentry. |
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.
Thanks for the PR, @AnirudhBhat! I added a few improvement ideas. Let me know what you think.
@@ -4251,6 +4251,7 @@ | |||
<string name="woopos_floating_toolbar_menu_open_content_description">Toolbar with card reader status. Menu is open. Double tap to interact.</string> | |||
<string name="woopos_floating_toolbar_pop_up_menu_content_description">Open toolbar menu</string> | |||
<string name="woopos_floating_toolbar_pop_up_menu_open_content_description">Popup menu with options. Swipe to navigate through items.</string> | |||
<string name="woopos_no_internet_message">It looks like you\'re not connected to the internet.\n\nEnsure your Wi-Fi is turned on. If you\'re using mobile data, make sure it\'s enabled in your device settings.</string> |
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.
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.
) | ||
) | ||
val state: StateFlow<WooPosHomeState> = _state | ||
|
||
private val _toastEvent = MutableSharedFlow<Int>() |
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.
💡 I'd improve the readability of the _toastEvent
prop type. I'd personally wrap the Int with a dedicated data class, e.g.
data class Toast(
@StringRes val message: Int,
)
even better could be to emit ready to use string:
data class Toast(
val message: String,
)
or alternatively
import kotlin.Int as ToastMessageStringRes
private val _toastEvent = MutableSharedFlow<ToastMessageStringRes>()
val toastEvent: SharedFlow<ToastMessageStringRes> = _toastEvent
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.
Thanks for the suggestion! Improved it here: f49db88
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.
LGTM
Closes: #12497
Description
This PR addresses the issue of handling no internet connectivity when attempting to connect to the card reader.
Previous Behavior:
When attempting to connect the card reader without an internet connection, the app would not provide any feedback or response. This was due to the app first checking whether all onboarding conditions were met before initiating the card reader connection. In the case of no internet, the app would navigate to an onboarding screen that explains the need for an internet connection. However, since the onboarding screens were not integrated into the POS mode, the app became unresponsive.
Updated Behavior:
With this PR, we now check for internet connectivity before attempting to start the WooPosCardReaderActivity. If no internet connection is detected, the activity is not launched, and instead, a toast message is displayed asking the user to ensure a proper internet connection before proceeding.
Steps to reproduce
Testing information
I've tested this on tablet emulator by turning on and off internet.
Images/gif
Before
Card.Reader.Disconnected.When.No.Internet.Connection.mov
After
card_reader_internet_issue.mp4
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: