Skip to content

Refactor: study options ViewModel migration#20720

Open
criticalAY wants to merge 3 commits intoankidroid:mainfrom
criticalAY:refactor/study-options-viewmodel
Open

Refactor: study options ViewModel migration#20720
criticalAY wants to merge 3 commits intoankidroid:mainfrom
criticalAY:refactor/study-options-viewmodel

Conversation

@criticalAY
Copy link
Copy Markdown
Contributor

Purpose / Description

Migrate the StudyOptionsFragment to use VM

Fixes

NA

Approach

See commits

How Has This Been Tested?

Manual test on Pixel 10 and unit test

Learning (optional, can help others)

NA

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

- Extract business logic from StudyOptionsFragment into a dedicated
ViewModel.
- Introduces DeckStudyData, StudyOptionsState sealed interface,
and moves collection queries and deck operations (rebuild, empty, unbury)
into the ViewModel.
Replace direct collection access and mutable state in the fragment with
ViewModel delegation. The fragment now observes StudyOptionsState via
StateFlow and delegates operations (refresh, rebuild, empty, unbury) to
StudyOptionsViewModel. Removes currentContentView, updateValuesFromDeckJob,
retryMenuRefreshJob, and the col property getter.
@david-allison
Copy link
Copy Markdown
Member

david-allison commented Apr 12, 2026

Can we defer this until 2.25? Lots of risk just before we go to beta

@david-allison david-allison added the Next version Changes to be merged in the next version, to keep the current release stable. label Apr 12, 2026
Copy link
Copy Markdown
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

The first commit introduces code without moving it, making it difficult for 'git blame' to work effectively.

The tests should ideally be introduced in the commit which introduces them in the ViewModel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Next version Changes to be merged in the next version, to keep the current release stable.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants