improvement: introduce DeckPickerViewModel#17690
Merged
lukstbit merged 5 commits intoankidroid:mainfrom Jan 8, 2025
Merged
Conversation
68eb0e2 to
2250587
Compare
david-allison
commented
Dec 29, 2024
| * @see deleteDeck | ||
| * @see DeckDeletionResult | ||
| */ | ||
| val deckDeletedNotification = MutableSharedFlow<DeckDeletionResult>() |
Member
Author
There was a problem hiding this comment.
This could be part of an 'undoableSnackbar' flow, didn't seem useful
david-allison
commented
Dec 29, 2024
AnkiDroid/src/main/java/com/ichi2/anki/deckpicker/DeckPickerViewModel.kt
Show resolved
Hide resolved
david-allison
commented
Dec 29, 2024
| decks.name(focusedDeck), | ||
| decks.cardCount(focusedDeck, includeSubdecks = true), | ||
| decks.isFiltered(focusedDeck), | ||
| decks.name(viewModel.focusedDeck), |
Member
Author
There was a problem hiding this comment.
@sanjaysargam showDeleteDeckConfirmationDialog is only used when pressing 'DEL', in all other cases, we delete unconditionally and show an 'undo' snackbar
Was this intentional?
Member
There was a problem hiding this comment.
Yes it is intentional.
KeyEvent.KEYCODE_DEL -> {
// This action on a deck should only occur when the user see the deck name very clearly,
// that is, when it appears in the trailing study option fragment
if (fragmented) {
if (event.isShiftPressed) {
// Shortcut: Shift + DEL - Delete deck without confirmation dialog
Timber.i("Shift+DEL: Deck deck without confirmation")
deleteDeck(focusedDeck)
} else {
// Shortcut: DEL
Timber.i("Delete Deck from keypress")
showDeleteDeckConfirmationDialog()
}
return true
}
}
mikehardy
approved these changes
Jan 6, 2025
Member
mikehardy
left a comment
There was a problem hiding this comment.
LGTM and here come the ViewModels 😄
fix conflict + second review
It will also be used in the Deck Picker
2250587 to
2903a0c
Compare
5 tasks
lukstbit
reviewed
Jan 7, 2025
Member
lukstbit
left a comment
There was a problem hiding this comment.
The code is ok, left some issues to discuss.
AnkiDroid/src/main/java/com/ichi2/anki/deckpicker/DeckPickerViewModel.kt
Outdated
Show resolved
Hide resolved
AnkiDroid/src/main/java/com/ichi2/anki/deckpicker/DeckPickerViewModel.kt
Show resolved
Hide resolved
We want to use a ViewModel for DeckPicker This is the start * extract 'focusedDeck' * will be used in the next commit
* inline confirmDeckDeletion * removing unnecessary 'dismiss' calls * extract `deleteDeck` * introduce `DeckDeletionResult`
review request
2903a0c to
b9b20d7
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Description
We want more ViewModels in 2025. Let it start
Approach
removeHow Has This Been Tested?
Deleted a deck in the UI of an API 34 emulator via context menu
Checklist