From 0d2e46feb58c5bdbf5ed5254cc673db39c0043fa Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 13 Aug 2022 12:05:05 +1000 Subject: [PATCH] Legacy undo & v2 queues must be cleared on backend op Fixes #12007 --- AnkiDroid/src/main/java/com/ichi2/libanki/ChangeManager.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/ChangeManager.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/ChangeManager.kt index dea1e800b2e3..f57c37220396 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/ChangeManager.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/ChangeManager.kt @@ -93,7 +93,12 @@ object ChangeManager { * to notify change subscribers of the changes. */ suspend fun undoableOp(handler: Any? = null, block: CollectionV16.() -> T): T { return withCol { - this.newBackend.block() + val result = newBackend.block() + // any backend operation clears legacy undo and resets study queues if it + // succeeds + clearUndo() + reset() + result }.also { withContext(Dispatchers.Main) { ChangeManager.notifySubscribers(it, handler)