Skip to content

Conversation

kidinov
Copy link
Contributor

@kidinov kidinov commented Apr 1, 2025

Closes: #13771
Closes: #13870

Description

The PR:

  • Fixed a bug when if the new products set coming the search state is hidden
  • That pull to refresh was available on the searching state
  • I renamed wrongly named high-level classes PaginationState and ContentViewState

Steps to reproduce

  • Open the POS and right-open open search
  • Notice that after a second, it's hidden

  • Try to do pull to refresh on the search state
  • Notice that products are shown

Testing information

Make sure that there is no regression regarding PTR, including variations

The tests that have been performed

above

Images/gif

04-01--09-43.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.

@kidinov kidinov marked this pull request as draft April 1, 2025 14:25
@dangermattic
Copy link
Collaborator

dangermattic commented Apr 1, 2025

1 Warning
⚠️ This PR is assigned to the milestone 22.1. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 1, 2025

📲 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
Commit018dc52
Direct Downloadwoocommerce-wear-prototype-build-pr13878-018dc52.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Apr 1, 2025

📲 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
Commit018dc52
Direct Downloadwoocommerce-prototype-build-pr13878-018dc52.apk

@kidinov kidinov requested a review from samiuelson April 2, 2025 07:25
@kidinov kidinov added the feature: point of sale POS project label Apr 2, 2025
@kidinov kidinov added this to the 22.1 milestone Apr 2, 2025
@kidinov kidinov marked this pull request as ready for review April 2, 2025 07:38
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 68.75000% with 30 lines in your changes missing coverage. Please review.

Project coverage is 38.19%. Comparing base (c8817b2) to head (018dc52).
Report is 76 commits behind head on trunk.

Files with missing lines Patch % Lines
...droid/ui/woopos/home/items/WooPosItemsViewModel.kt 63.88% 9 Missing and 4 partials ⚠️
...home/items/variations/WooPosVariationsViewModel.kt 41.66% 5 Missing and 2 partials ⚠️
...ce/android/ui/woopos/home/items/WooPosItemsList.kt 0.00% 4 Missing ⚠️
...id/ui/woopos/home/items/WooPosItemsSearchHelper.kt 55.55% 2 Missing and 2 partials ⚠️
...poseui/component/WooPosPaginationErrorIndicator.kt 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #13878   +/-   ##
=========================================
  Coverage     38.19%   38.19%           
- Complexity     9316     9322    +6     
=========================================
  Files          2085     2085           
  Lines        115154   115177   +23     
  Branches      14675    14680    +5     
=========================================
+ Hits          43980    43989    +9     
- Misses        67174    67186   +12     
- Partials       4000     4002    +2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samiuelson samiuelson self-assigned this Apr 2, 2025
@samiuelson
Copy link
Contributor

@coderabbitai review

Copy link

coderabbitai bot commented Apr 2, 2025

📝 Walkthrough

Walkthrough

The changes refactor state management across the WooCommerce POS UI. The generic PaginationState and Boolean flag reloadingWithPullToRefresh have been replaced with the namespaced WooPosPaginationState and the dedicated enum WooPosPullToRefreshState. Updates span UI components, view model logic, search features, and test cases, ensuring that pagination and pull-to-refresh states are handled in a more structured and explicit way throughout the codebase.

Changes

File(s) Change Summary
.../woopos/common/composeui/component/WooPosPaginationErrorIndicator.kt,
.../woopos/home/items/WooPosBaseViewState.kt,
.../woopos/home/items/WooPosItemsViewState.kt
Replaced generic PaginationState and Boolean reloadingWithPullToRefresh with WooPosPaginationState and WooPosPullToRefreshState. Updated imports and default state values.
.../woopos/home/items/WooPosItemsList.kt,
.../woopos/home/items/WooPosItemsScreen.kt
Updated composable signatures and state handling to use WooPosContentViewState, WooPosPaginationState, and pullToRefreshState. Added a new callback parameter for pull-to-refresh actions.
.../woopos/home/items/search/WooPosItemsSearchHelper.kt,
.../woopos/home/items/search/WooPosItemsSearchScreen.kt,
.../woopos/home/items/search/WooPosItemsSearchViewModel.kt,
.../woopos/home/items/search/WooPosItemsSearchViewState.kt
Revised search components: integrated new state types, added isSearchOpen() method, and updated preview parameters and view model signatures to reflect the new state structure.
.../woopos/home/items/WooPosVariationsViewState.kt,
.../woopos/home/items/variations/WooPosVariationsScreen.kt,
.../woopos/home/items/variations/WooPosVariationsViewModel.kt
Updated variations components by replacing boolean refresh flags with pullToRefreshState and using WooPosPaginationState for pagination management in screens and view models.
.../woopos/home/items/WooPosItemsViewModel.kt Updated product loading and state conversion methods to use WooPosPaginationState, including the addition of an extension function for mapping products to view state.
Test Files (multiple paths under /test/kotlin/com/woocommerce/android/ui/woopos/) Adjusted test assertions and state initializations to validate the new WooPosPaginationState and WooPosPullToRefreshState configurations.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI as WooPosItemsScreen
  participant List as MainItemsList
  participant VM as WooPosItemsViewModel

  User->>UI: Initiates pull-to-refresh gesture
  UI->>List: Trigger onPullToRefreshTriggered callback
  List->>VM: Execute refresh logic
  VM->>VM: Update pullToRefreshState to Refreshing<br>and load products with WooPosPaginationState
  VM-->>List: Emit updated state
  List-->>UI: Render refreshed content based on new state
  UI-->>User: Display updated product list
Loading

Assessment against linked issues

Objective Addressed Explanation
[#13771: It possible to pull to refresh when search is visible]
[#13870: Implement selection of a popular and recent search] No code changes for popular/recent search selection logic are present.

Possibly related PRs

Suggested labels

type: enhancement, type: task

Suggested reviewers

  • atorresveiga
  • irfano
  • JorgeMucientes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewModelTestSelectionViewState.kt (1)

339-347: Consider adding a test for WooPosPaginationState.CanLoadMore.

While the tests cover loading, none, and error states, there doesn't appear to be coverage for the .CanLoadMore state that likely exists in the enum. Consider adding a test case that verifies this state transition as well.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8817b2 and 018dc52.

📒 Files selected for processing (17)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/composeui/component/WooPosPaginationErrorIndicator.kt (2 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosBaseViewState.kt (1 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsList.kt (4 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsScreen.kt (9 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsSearchHelper.kt (2 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewModel.kt (4 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewState.kt (2 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosVariationsViewState.kt (1 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchScreen.kt (2 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewModel.kt (4 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewState.kt (2 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/variations/WooPosVariationsScreen.kt (4 hunks)
  • WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/variations/WooPosVariationsViewModel.kt (5 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsSearchHelperTest.kt (1 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewModelTestSelectionViewState.kt (3 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewModelTestSelectionViewState.kt (3 hunks)
  • WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/variations/WooPosVariationsViewModelTest.kt (5 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsList.kt (1)
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsUIEvent.kt (2)
  • item (3-17)
  • item (4-4)
🔇 Additional comments (49)
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/variations/WooPosVariationsScreen.kt (5)

49-49: Appropriate import added for the new state enum

The addition of the WooPosPullToRefreshState import is correctly implemented to support the new state management approach replacing the boolean flag.


109-110: Good refactoring to use enum instead of boolean flag

Replacing the boolean reloadingWithPullToRefresh with the explicit enum state WooPosPullToRefreshState.Refreshing improves code readability and makes the state management more robust.


116-119: Enhanced pull-to-refresh with proper state control

The modification of the pullRefresh modifier to include an enabled parameter is a good improvement. This allows explicit control over when pull-to-refresh should be available based on the current state, addressing the issue mentioned in the PR where pull-to-refresh should be available during search.


180-180: Consistent state check for pull refresh indicator

The PullRefreshIndicator is now properly using the same state enum check as the rest of the component, ensuring consistent behavior throughout the pull-to-refresh implementation.


285-285: Preview state updated to match new implementation

The preview's state initialization has been correctly updated to use the new WooPosPullToRefreshState.Refreshing enum value, maintaining consistency with the actual implementation.

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/variations/WooPosVariationsViewModelTest.kt (1)

10-10: LGTM! Successful class rename refactoring.

The import and assertion changes correctly replace the generic PaginationState class with the more specific WooPosPaginationState class. This aligns with the PR objective of renaming incorrectly labeled high-level classes and makes the pagination state representation consistent across the codebase.

Also applies to: 216-216, 284-284, 310-310, 333-333

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewModelTestSelectionViewState.kt (2)

13-13: Good namespacing approach.

The import switch from a generic PaginationState to a more specific WooPosPaginationState follows good namespacing practices. This change is aligned with the PR objective of renaming high-level classes for better clarity.


343-343: Test assertions properly updated to use new pagination state class.

The test assertions have been correctly updated to use WooPosPaginationState instead of the previous generic PaginationState. This ensures the tests continue to function as expected with the new class names.

Also applies to: 347-347, 368-368, 371-371

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/variations/WooPosVariationsViewModel.kt (5)

14-15: Well-structured imports for improved state management

The introduction of domain-specific state classes WooPosPaginationState and WooPosPullToRefreshState replaces generic state management with more specific, namespaced alternatives. This aligns with the PR objective to rename incorrectly labeled high-level classes.


104-107: Consistent pagination state naming

The replacement of the generic PaginationState with the domain-specific WooPosPaginationState improves code clarity and maintainability by using consistent naming conventions throughout the codebase.


142-154: Enhanced state management for pull-to-refresh

The refactoring from a boolean flag (reloadingWithPullToRefresh) to an explicit state enum (WooPosPullToRefreshState.Refreshing) improves code readability and flexibility. This approach provides a more structured way to manage pull-to-refresh states across different view states and addresses the PR objective of ensuring pull-to-refresh functionality is available during search.


166-166: Consistent pagination state update in loadMore

The pagination state update properly uses the namespaced WooPosPaginationState.Loading, maintaining consistency with the other state changes in this file.


184-184: Consistent error state handling

The error case now correctly references WooPosPaginationState.Error, completing the consistent application of the new state classes throughout the pagination logic.

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewModelTestSelectionViewState.kt (3)

197-197: Good implementation of naming change.

The assertion has been updated to use the new namespaced WooPosPaginationState.None in place of the previous generic PaginationState.None. This aligns with the PR objective of renaming incorrectly labeled high-level classes to more specific ones.


235-235: Good implementation of naming change.

The assertion has been updated to use the new namespaced WooPosPaginationState.None, consistent with the changes made throughout the codebase.


272-273: Good implementation of namespaced classes.

Both changes here are aligned with the PR objectives:

  1. Changed the cast to use WooPosContentViewState instead of the previous generic ContentViewState
  2. Updated the assertion to use WooPosPaginationState.Error class for type checking

This provides better namespace separation and reduces the risk of name collisions with other components.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchScreen.kt (2)

23-24: Updated imports for better state management.

The imports have been correctly updated to use the new namespaced state classes, which aligns with the PR objective of renaming high-level classes.


163-164: State management improvement.

The preview code now uses the new enum-based state system instead of boolean flags, making the pull-to-refresh state more explicit and easier to understand.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/composeui/component/WooPosPaginationErrorIndicator.kt (2)

35-36: Updated imports to use the namespaced state classes.

The imports have been correctly updated to use the new namespaced state classes, which is consistent with the changes in other files.


151-152: Improved state representation in the preview.

The code now uses the more expressive enum-based state system instead of boolean flags, making it clear that the pagination is in an error state and pull-to-refresh is actively refreshing.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosBaseViewState.kt (4)

3-5: Enhanced state management with enums instead of booleans.

The base view state now uses the more expressive WooPosPullToRefreshState enum instead of a boolean flag, allowing for more clearly defined states.


7-11: Improved interface naming and state properties.

The interface has been renamed from ContentViewState to WooPosPullToRefreshState for better namespacing, and the state properties have been updated to use the dedicated enum types instead of booleans.


13-17: Created namespaced pagination state class.

The new sealed class properly namespaces the pagination states, making the code more maintainable and reducing potential naming conflicts.


19-21: Added pull-to-refresh state enum.

This enum provides a clear representation of the three possible states for pull-to-refresh, which is more expressive than the previous boolean flag.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsSearchHelper.kt (2)

99-102: Added helper method to check if search is open.

This new method encapsulates the logic for checking if the search is in an open state, which helps fix the issue where search state was being hidden when products arrive.


147-160: Key fix: Conditionally enable/disable pull-to-refresh based on search state.

This logic directly addresses the PR objectives by:

  1. Enabling pull-to-refresh when search is hidden or closed
  2. Disabling pull-to-refresh when search is open

This ensures proper behavior during search and prevents conflicts between the two interactions.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewModel.kt (1)

14-14: Good refactoring to feature-specific state types.

Replacing the generic PaginationState with the more specific WooPosPaginationState improves code organization and maintainability. This namespace-based approach reduces the risk of state conflicts between different features, making the code more modular and easier to reason about.

Also applies to: 147-147, 157-157, 196-196

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsList.kt (1)

71-71: Improved UI state management implementation.

The changes effectively update the UI components to work with the more specific state types (WooPosContentViewState and WooPosPaginationState). Particularly noteworthy is the change from the boolean reloadingWithPullToRefresh to the more expressive pullToRefreshState in the LaunchedEffect. This enhancement allows for more nuanced state handling and fixes the pull-to-refresh functionality during search, directly addressing one of the PR objectives.

Also applies to: 114-126, 411-411, 425-425

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsSearchHelperTest.kt (2)

208-209: Updated test helper to use the new state types.

The test helper's createContentState method has been properly updated to use WooPosPaginationState.None and initialize the new pullToRefreshState property with WooPosPullToRefreshState.Enabled, ensuring consistency with the implementation changes.


214-254: Excellent test coverage for the pull-to-refresh behavior.

These new tests provide thorough verification of the pull-to-refresh behavior in different search states:

  1. When search is closed, pull-to-refresh is enabled
  2. When search query is being changed, pull-to-refresh is disabled (preventing accidental refreshes)
  3. When search is hidden, pull-to-refresh is enabled

The tests directly verify the core functionality mentioned in the PR objectives around pull-to-refresh availability during search, ensuring the changes work as intended.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewState.kt (3)

7-9: Good refactoring from boolean to enum-based state management.

Replacing the boolean reloadingWithPullToRefresh with an enum-based pullToRefreshState provides more explicit state management and allows for future extension if additional states are needed. This change directly supports the PR objective of improving pull-to-refresh functionality.


14-17: Well-structured state type refactoring.

The Content class has been properly updated to:

  1. Use the more specific WooPosPaginationState instead of generic PaginationState
  2. Add the new pullToRefreshState property with a sensible default
  3. Implement the feature-specific WooPosContentViewState interface

These changes create a more maintainable and organized state hierarchy that aligns with the PR objectives.


31-42: Consistent state management across all view states.

The Loading, Error, and Empty state classes have been consistently updated to use the new pullToRefreshState property with appropriate defaults. This ensures that pull-to-refresh behavior is properly managed regardless of which state the UI is in.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsViewModel.kt (5)

213-233: Improved state handling with namespaced pull-to-refresh states

The refactoring from generic state types to specific WooPOS state types improves type safety and makes the code more self-explanatory. The conditional logic now properly maintains search state when new products arrive, addressing the bug mentioned in the PR objectives.


246-252: Consistent use of WooPosPullToRefreshState enum in reload state

The implementation now uses the enum-based state management instead of boolean flags, providing more expressive and maintainable code.


270-288: Good extraction of conversion logic into a dedicated function

Moving the product-to-viewstate conversion logic into a separate extension function improves modularity and readability.


300-300: Consistent use of WooPosPaginationState.Loading

Updated pagination state handling maintains consistency with the overall state management refactoring.


308-308: Consistent error handling with WooPosPaginationState.Error

Error state handling is now aligned with the namespaced pagination state system.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/search/WooPosItemsSearchViewState.kt (2)

3-7: Updated imports to use namespaced state classes

The imports have been correctly updated to use the namespaced WooPos-specific state classes, aligning with the overall refactoring effort.


17-19: Migrated to enum-based state management

The Content class now properly implements the WooPosContentViewState interface with the new state types. This improves type safety and allows for more nuanced state control beyond simple booleans.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosVariationsViewState.kt (3)

4-5: Updated base class constructor to use WooPosPullToRefreshState

The constructor parameter is now properly typed as WooPosPullToRefreshState rather than a boolean, improving type safety and expressiveness.


7-11: Consistent state type updates in Content class

The Content class now properly uses the namespaced state types in line with the overall refactoring, improving type safety and clarity.


13-24: Consistent pull-to-refresh state handling across all view states

All view state classes (Loading, Error, Empty) now consistently use the WooPosPullToRefreshState type, ensuring a uniform approach to state management throughout the application.

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsScreen.kt (6)

110-111: Added pull-to-refresh trigger callback

The onPullToRefreshTriggered callback is now properly passed to the MainItemsList function, enabling the pull-to-refresh functionality during search state.


128-133: Added pull-to-refresh callback parameter

The MainItemsList function now accepts an onPullToRefreshTriggered callback, making the component more modular and reusable.


130-141: Enhanced pull-to-refresh state management

The implementation now properly creates and configures the pull-to-refresh state using the enum-based approach. The enabled parameter ensures that pull-to-refresh is only available when appropriate, addressing the PR objective.


228-229: Updated refreshing state check

The PullRefreshIndicator now correctly uses the WooPosPullToRefreshState.Refreshing enum value instead of a boolean flag to determine when to show the refreshing indicator.


385-487: Comprehensive updates to preview functions

All preview functions have been updated to use the new state types, maintaining the completeness of the refactoring across production and preview code.


541-594: Continued consistent state updates in remaining previews

The remaining preview implementations maintain consistency with the new state management approach.

Copy link
Contributor

@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:

@samiuelson samiuelson merged commit 80b02d9 into trunk Apr 2, 2025
20 checks passed
@samiuelson samiuelson deleted the 13771-woo-posproducts-search-it-possible-to-pull-to-refresh-when-search-is-visible branch April 2, 2025 15:10
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
5 participants