Skip to content
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

Merged
merged 14 commits into from
Sep 13, 2024

Conversation

AnirudhBhat
Copy link
Contributor

@AnirudhBhat AnirudhBhat commented Sep 10, 2024

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

  1. Navigate to POS mode (More menu -> POS mode)
  2. Click on connect to card reader button
  3. While connecting, turn off the internet
  4. Cancel the ongoing connection dialog
  5. Try to connect to card reader again and notice the button won't respond anymore.

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
  • I have considered if this change warrants release notes and have added them to 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:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@AnirudhBhat AnirudhBhat added type: bug A confirmed bug. feature: point of sale POS project labels Sep 10, 2024
@AnirudhBhat AnirudhBhat added this to the 20.4 milestone Sep 10, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 10, 2024

2 Warnings
⚠️ Class Toast is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ This PR is assigned to the milestone 20.4. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 10, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit65f8eeb
Direct Downloadwoocommerce-wear-prototype-build-pr12569-65f8eeb.apk

@AnirudhBhat AnirudhBhat marked this pull request as ready for review September 10, 2024 04:23
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 10, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit65f8eeb
Direct Downloadwoocommerce-prototype-build-pr12569-65f8eeb.apk

@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2024

Codecov Report

Attention: Patch coverage is 47.61905% with 11 lines in your changes missing coverage. Please review.

Project coverage is 40.61%. Comparing base (af19b54) to head (65f8eeb).
Report is 17 commits behind head on trunk.

Files with missing lines Patch % Lines
...erce/android/ui/woopos/home/WooPosHomeViewModel.kt 33.33% 6 Missing ⚠️
...erce/android/ui/woopos/util/WooPosNetworkStatus.kt 0.00% 4 Missing ⚠️
...d/ui/woopos/home/toolbar/WooPosToolbarViewModel.kt 85.71% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@samiuelson samiuelson left a 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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string is not rendered correctly, new lines are cut:
Screenshot_20240912_171300

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up! Fixed

no_internet_toast_message

)
)
val state: StateFlow<WooPosHomeState> = _state

private val _toastEvent = MutableSharedFlow<Int>()
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Collaborator

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

@AnirudhBhat AnirudhBhat merged commit 618cb95 into trunk Sep 13, 2024
14 checks passed
@AnirudhBhat AnirudhBhat deleted the issue/12497-pos-internet-issue branch September 13, 2024 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Woo POS] Cannot reconnect to Reader after turning internet off and on
6 participants