-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix: Update all associated cardIds of a note #18012
base: main
Are you sure you want to change the base?
Fix: Update all associated cardIds of a note #18012
Conversation
…just the currentEditedCard
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
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.
Small request. The fix looks good to me
@@ -1261,7 +1261,10 @@ class NoteEditor : | |||
// changed did? this has to be done first as remFromDyn() involves a direct write to the database | |||
if (currentEditedCard != null && currentEditedCard!!.currentDeckId() != deckId) { | |||
reloadRequired = true | |||
undoableOp { setDeck(listOf(currentEditedCard!!.id), deckId) } | |||
// Obtain all card IDs for the current note | |||
val allCardIds = editorNote!!.cardIds(getColUnsafe) |
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.
val allCardIds = editorNote!!.cardIds(getColUnsafe) | |
val allCardIds = withCol { editorNote!!.cardIds(this) } |
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.
Because there are many getColUnsafe
calls in NoteEditor
and because the editor will be gone eventually, I'm approving despite of the change request
@@ -1261,7 +1261,10 @@ class NoteEditor : | |||
// changed did? this has to be done first as remFromDyn() involves a direct write to the database | |||
if (currentEditedCard != null && currentEditedCard!!.currentDeckId() != deckId) { | |||
reloadRequired = 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.
Has this been tested:
- In the Card Browser in
Cards
mode - From the Reviewer, editing a single card
From a brief overview of the code, this code would update all cards from the note, which is not expected.
Hi @david-allison yes I have tested it out in both of the scenarios you mentioned (screen-recording below) My understanding is that a note change should be propagated to all associated cards. ie In the bug issue - a cloze note type has two associated cards and a change in deck type for card #1 should be the same for card #2. Please correct me if I am wrong here and I'll update accordingly. |
Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
Only in 'Notes' mode. If a user is in 'Cards' mode, or edits a single card whilst reviewing, only the deck of the card should be affected |
This PR fixes a bug in the Note Editor where only the currentEditedCard deckID was being updated when a note was modified, instead of updating all associated cards linked to that note.
To address this issue:
The fix has been tested with the following scenarios:
✅ Edited a cloze note three times and verified that all linked cards updated correctly.
✅ Checked behavior when undoing changes, ensuring all cards revert correctly.
✅ Manually tested on:
Emulator (Pixel_3a_API_34_arm64-v8a)
✅ Automated Tests:
Ran the concrete methods FieldEditLineTest and NoteEditorTabOrderTest.kt
ankiDroid-screen_recording.webm
There's a separate issue that I noticed re: Congrats Snackbar, even when I am not "reviewing" the card if the edit is done via AbstractFlashcardViewer and if there are no more cards left in the deck after I change the deck type of a cloze note with two associated cards , the snackbar is triggered as there are no more cards left in the deck.
From the initial investigation, if no card is available in the current deck, the reviewer closes with RESULT_NO_MORE_CARDS, triggering the congrats message. I just wanted to flag this - I can create a new bug for this if it makes sense