Skip to content

[Dynamic Dashboard] Reviews card: business logic #11477

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

Merged
merged 6 commits into from
May 15, 2024

Conversation

hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented May 9, 2024

Part of: #11474

Description

This PR adds the business logic part of the reviews card, I wanted to create this PR in this state to keep it small, and to have a chance to discuss how to approach the new cards with the feature flag.
The UI, the navigation to review details and handling of error state will be added on separate PRs.

Testing instructions

  1. Open the app.
  2. Open the widget editor screen.
  3. Confirm that a new card "Most recent reviews" was added, and that it's unselected.
  4. Select it.
  5. Go back.
  6. Confirm reviews are loaded (ignore the appearance).

Images/gif

  • 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.

@hichamboushaba hichamboushaba added type: enhancement A request for an enhancement. feature: dashboard Related to home screen project labels May 9, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented May 9, 2024

3 Warnings
⚠️ Class DashboardReviewsViewModel is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ Class Success is missing tests, but unit-tests-exemption label was set to ignore this.
⚠️ PR is not assigned to a milestone.
1 Message
📖

This PR contains changes to Tracks-related logic. Please ensure (author and reviewer) the following are completed:

  • The tracks events must be validated in the Tracks system.
  • Verify the internal Tracks spreadsheet has also been updated.
  • Please consider registering any new events.
  • The PR must be assigned the category: tracks label.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 9, 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
FlavorJalapeno
Build TypeDebug
Commitf873268
Direct Downloadwoocommerce-prototype-build-pr11477-f873268.apk

Comment on lines +35 to +50
val viewState = combine(refreshTrigger, status) { refresh, status -> Pair(refresh, status) }
.transformLatest { (refresh, status) ->
emit(ViewState.Loading)
emitAll(
observeMostRecentReviews(forceRefresh = refresh.isForced, status = status)
.map { result ->
result.fold(
onSuccess = { reviews ->
ViewState.Success(reviews)
},
onFailure = { ViewState.Error }
)
}
)
}
.asLiveData()
Copy link
Member Author

Choose a reason for hiding this comment

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

This logic follows approach 2 on what we decided, as it's quite simple to implement for cards with existing caching, I think it would make sense to use it even if iOS team don't, WDYT?

@hichamboushaba hichamboushaba added the category: tracks Related to analytics, including Tracks Events. label May 10, 2024
@hichamboushaba hichamboushaba requested a review from 0nko May 10, 2024 10:30
@hichamboushaba hichamboushaba marked this pull request as ready for review May 10, 2024 10:30
@hichamboushaba hichamboushaba added the status: do not merge Dependent on another PR, ready for review but not ready for merge. label May 10, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 10, 2024

Codecov Report

Attention: Patch coverage is 1.69492% with 116 lines in your changes are missing coverage. Please review.

Project coverage is 40.78%. Comparing base (e734909) to head (f873268).

Files Patch % Lines
...ommerce/android/ui/reviews/ReviewListRepository.kt 0.00% 41 Missing ⚠️
...droid/ui/dashboard/reviews/DashboardReviewsCard.kt 0.00% 34 Missing ⚠️
.../ui/dashboard/reviews/DashboardReviewsViewModel.kt 0.00% 34 Missing ⚠️
...ommerce/android/ui/dashboard/DashboardContainer.kt 0.00% 3 Missing ⚠️
...ce/android/ui/dashboard/data/DashboardDataStore.kt 0.00% 3 Missing ⚠️
...e/android/ui/dashboard/data/DashboardRepository.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #11477      +/-   ##
============================================
- Coverage     40.84%   40.78%   -0.06%     
  Complexity     5180     5180              
============================================
  Files          1068     1070       +2     
  Lines         62283    62374      +91     
  Branches       8495     8521      +26     
============================================
+ Hits          25437    25438       +1     
- Misses        34559    34649      +90     
  Partials       2287     2287              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hichamboushaba hichamboushaba force-pushed the issue/11474-dynamic-dashboard-reviews-card branch from 5a0487f to 5b1befd Compare May 10, 2024 14:44
Base automatically changed from dynamic-dashboard/feature-flag-m2 to trunk May 10, 2024 15:56
@hichamboushaba hichamboushaba removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label May 13, 2024
Copy link
Contributor

@0nko 0nko left a comment

Choose a reason for hiding this comment

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

When I test the PR, even after logging out and clearing the storage the Reviews card is always shown by default.

@0nko 0nko self-assigned this May 15, 2024
@hichamboushaba
Copy link
Member Author

hichamboushaba commented May 15, 2024

When I test the PR, even after logging out and clearing the storage the Reviews card is always shown by default.

@0nko Yes, this is fixed on the next PR, this happens because the logic of adding only M1 cards by default wasn't agreed on, and it wasn't added to this PR.

@0nko
Copy link
Contributor

0nko commented May 15, 2024

Okay, I just mentioned that because the test instructions say Confirm that a new card "Most recent reviews" was added, and that it's unselected.

Copy link
Contributor

@0nko 0nko left a comment

Choose a reason for hiding this comment

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

:shipit:

@0nko 0nko merged commit 31c9578 into trunk May 15, 2024
14 of 15 checks passed
@0nko 0nko deleted the issue/11474-dynamic-dashboard-reviews-card branch May 15, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: tracks Related to analytics, including Tracks Events. feature: dashboard Related to home screen project type: enhancement A request for an enhancement. unit-tests-exemption
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants