-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: remove extra undo entry when adding note #19516
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
Conversation
|
Tests fail, and that probably means that the fix is wrong. Please run CI before making a PR. You can run it in your GH branch as well if you don't want to run it locally. |
|
The saveNoteWithProgress() function was calling both notetypes.save() and addNote() inside the same undoableOp block. This created two separate backend undo entries:
When undoing the note, the unlabeled entry was exposed, causing undoAvailable() to return false and hiding previous operations.
Trade-off: This is a temporary fix. The proper solution requires backend changes i.e have addNote() automatically update notetype.did, |
So, we should wait for that. |
|
The backend already handles "last used deck" tracking automatically via |
AnkiDroid/src/main/java/com/ichi2/anki/instantnoteeditor/InstantEditorViewModel.kt
Outdated
Show resolved
Hide resolved
7313230 to
28eb4cf
Compare
28eb4cf to
b93ed17
Compare
david-allison
left a comment
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.
Squashed, updated commit message, fixed an unnecessary newline change, and force pushed
Thanks!!!!
Updating the card template is handled by the backend so we did not need to save it ---- test: update NoteEditorTest to use modern defaultDeckForNoteType API: The test "decide by note type preference - 13931" was using deprecated notetype.did field. Updated to use defaultDeckForNoteType() which queries the backend's automatic "last used deck" tracking. ---- fix: remove deprecated notetype.did usage to fix undo stack as after performing a deck operation then adding a note, undoing the note would clear the undo queue. This was caused by the deprecated notetype.did API requiring a notetypes.save() call, which created an unlabeled undo entry. ---- fix: remove notetypes.save() to fix undo queue breaking (Issue 19508) Removed notetypes.save() from saveNoteWithProgress() to prevent unlabeled undo entry that was breaking the undo stack after undoing a note addition. Fixes 19508 Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
b93ed17 to
1a42898
Compare
Purpose / Description
When undoing the note, the unlabeled entry from
notetypes.save()would be exposed, causingundoAvailable()to return false and hiding previous deck operations from the undo stack.Fixes
Approach
Remove
notetypes.save()fromundoableOpblock as it's redundant - the note already contains notetype information.How Has This Been Tested?
undo.mp4
Checklist
Please, go through these checks before submitting the PR.