From 14bcb3cf3c2c3e0b6aa81952ef4cc698f1c33ce3 Mon Sep 17 00:00:00 2001 From: Aryan171 <62366692+Aryan171@users.noreply.github.com> Date: Sun, 9 Nov 2025 17:29:57 +0530 Subject: [PATCH] feat(reviewer): Check for timebox limit after answering card - Previously, the timebox limit was checked whenever the updateCurrentCard function was called, which lead to unnecessary timebox reached popup, this logic has been moved to the answerCardInner function. This makes it so that the popup is only shown when a card has been answered. --- AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt index a23adcde7375..4cffcc373a9b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt @@ -1208,11 +1208,16 @@ open class Reviewer : topCard.renderOutput(this@withCol, reload = true) } } - state?.timeboxReached?.let { dealWithTimeBox(it) } + currentCard = state?.topCard queueState = state } + /** + * Answer the current card, update the scheduler and checks if the timebox limit has been reached + * and, if so, displays a dialog to the user + * @param rating The user's rating for the card + */ override suspend fun answerCardInner(rating: Rating) { val state = queueState!! val cardId = currentCard!!.id @@ -1235,6 +1240,12 @@ open class Reviewer : showSnackbar(leechMessage, Snackbar.LENGTH_SHORT) } } + + // showing the timebox reached dialog if the timebox is reached + val timebox = withCol { timeboxReached() } + if (timebox != null) { + dealWithTimeBox(timebox) + } } private suspend fun dealWithTimeBox(timebox: Collection.TimeboxReached) {