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

Issue 416: Refactor pager code of edit categories screen #524

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

josmith42
Copy link
Contributor

@josmith42 josmith42 commented Apr 11, 2024

Description:

  • Partial solution for Remove duplicate category state in EditCategoriesViewModel #416
  • VocableFragementStateAdapter:
    • Fix return value of getItemCount()
    • Replace notifyDataSetChanged() with notifyItemInserted() and notifyItemRemoved()
  • EditCategoriesFragment:
    • Use post {} for setting categoryPageNumber (wasn't always getting set correctly before)
    • Move setting of adapter so that it's called once instead of every time data changes
    • Remove broken setting of current page to "middle" (now defaults to first page)
  • Make LegacyFragmentStateAdapter for use in other subclasses that haven't been changed yet
  • EditCategoriesViewModel: replace liveOrderCategoryList and liveAddRemoveCategoryList in favor of a single categoryList that uses categories() flow from categoriesUseCase
  • EditCategoriesListFragment: fix crash when removing an element caused pager to go down a page

Screenshots:
n/a

  • Acceptance Criteria satisfied
  • Regression Testing

* VocableFragementStateAdapter:
  * Fix return value of getItemCount()
  * Replace notifyDataSetChanged() with notifyItemInserted() and notifyItemRemoved()
* EditCategoriesFragment:
  * Use post {} for setting categoryPageNumber (wasn't always getting set correctly before)
  * Move setting of adapter so that it's called once instead of every time data changes
  * Remove broken setting of current page to "middle" (now defaults to first page)
* Make LegacyFragmentStateAdapter for use in other subclasses that haven't been changed yet
* EditCategoriesViewModel: liveOrderCategoryList and liveAddRemoveCategoryList in favor of a single categoryList that uses categories() flow from categoriesUseCase
* EditCategoriesListFragment: fix crash when removing an element caused pager to go down a page
@josmith42 josmith42 force-pushed the refactor/edit-categories-pager branch from fec6fbe to eb85a0a Compare April 11, 2024 15:11
@mattttvaughn
Copy link
Contributor

Seeing something funky going on here. If you go to the categories page and keep trying to move the bottom most category on a page down, the moving doesn't happy as expected and if you do it enough it'll crash

vocable_crash.webm

@@ -23,7 +24,15 @@ class FakeCategoriesUseCase : ICategoriesUseCase {
)

override fun categories(): Flow<List<Category>> {
return _categories
return _categories.map {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to make this change to get the fake to match the behavior of the real use case. (I know, I know. The real solution is to refactor the test to use the real use case. I am just not prepared to do that as a part of this PR.)

@josmith42
Copy link
Contributor Author

@mattttvaughn I fixed the crash you raised up. Please take a look! 🙏

@josmith42 josmith42 merged commit a57ac68 into main Apr 11, 2024
3 checks passed
@josmith42 josmith42 deleted the refactor/edit-categories-pager branch April 11, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants