-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
improvement: introduce DeckPickerViewModel #17690
Conversation
68eb0e2
to
2250587
Compare
* @see deleteDeck | ||
* @see DeckDeletionResult | ||
*/ | ||
val deckDeletedNotification = MutableSharedFlow<DeckDeletionResult>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be part of an 'undoableSnackbar' flow, didn't seem useful
AnkiDroid/src/main/java/com/ichi2/anki/deckpicker/DeckPickerViewModel.kt
Show resolved
Hide resolved
decks.name(focusedDeck), | ||
decks.cardCount(focusedDeck, includeSubdecks = true), | ||
decks.isFiltered(focusedDeck), | ||
decks.name(viewModel.focusedDeck), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SanjaySargam showDeleteDeckConfirmationDialog
is only used when pressing 'DEL', in all other cases, we delete unconditionally and show an 'undo' snackbar
Was this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and here come the ViewModels 😄
fix conflict + second review
It will also be used in the Deck Picker
2250587
to
2903a0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's move forward!
Purpose / Description
We want more ViewModels in 2025. Let it start
Approach
remove
How Has This Been Tested?
Deleted a deck in the UI of an API 34 emulator via context menu
Checklist