fix: select next deck after deletion to prevent Default deck appearing in StudyOptionsFragment#21285
fix: select next deck after deletion to prevent Default deck appearing in StudyOptionsFragment#21285sanjaysargam wants to merge 1 commit into
Conversation
…g in StudyOptionsFragment
lukstbit
left a comment
There was a problem hiding this comment.
Wait for another opinion but I think it would be better if the next selected deck after deleting a deck is one of the deleted deck's siblings or its parent(if it was the only child) so the selection doesn't jump(possible out of screen).
david-allison
left a comment
There was a problem hiding this comment.
In addition: the ViewModels to be well-tested, as these will continue to be core functionality after our move to Compose
- Only one
opChangesis published - A few tests about the next deck: child deck, child deck with sibling before/after; child deck with both siblings; parent deck
| nextDeckId = sched | ||
| .deckDueTree() | ||
| .children | ||
| .firstOrNull { it.did != DEFAULT_DECK_ID } | ||
| ?.did ?: DEFAULT_DECK_ID |
There was a problem hiding this comment.
I agree with lukstbit: define a 'basic' algorithm to select the next node within the tree/list
| .children | ||
| .firstOrNull { it.did != DEFAULT_DECK_ID } | ||
| ?.did ?: DEFAULT_DECK_ID | ||
| decks.select(nextDeckId) |
There was a problem hiding this comment.
Look into using decks.setCurrent() which returns an opChanges - you will want to test ACTIVE_DECKS is set as expected
Then, consider using two withCol calls, collect the opChanges, combine them, publish as one event
| val changes = | ||
| undoableOp { | ||
| val opChanges = decks.remove(listOf(did)) | ||
| // After deletion: decks.current() reverts to Default. Select the first |
There was a problem hiding this comment.
This comment feels 'Claude':
- Make it less verbose
- State that this explicitly deviates from Anki Desktop
- Mention all of:
- Unexpected scrolling around the deck list
- Selecting a 'Default' deck which is not visible in the sidebar (allowing it to be studied)
- Fragmented View
Note
Assisted-by: Claude Opus 4.8
Purpose / Description
On tablets, deleting a deck causes
StudyOptionsFragmentto display the Default deck, even when other non-Default decks remain.Fixes
Approach
call sched.deckDueTree() to find the first remaining non-Default deck and decks.select() it, so that when StudyOptionsFragment.opExecuted() subsequently calls withCol { decks.current() }, it reads the correct deck instead of the Default that the backend resets to after removal.
How Has This Been Tested?
Medium Tablet API 35
Checklist
Please, go through these checks before submitting the PR.