mirror of
https://github.com/ankitects/anki.git
synced 2026-01-11 13:03:55 -05:00
Prevent "not at top of queue" error
Because take_while was replaced by filter in intraday_now_iter, the learning card that is shown first may not be at the top of the queue.
This commit is contained in:
parent
bef595ae13
commit
9cf59e4a5d
1 changed files with 7 additions and 11 deletions
|
|
@ -159,17 +159,13 @@ impl CardQueues {
|
||||||
/// Remove the provided card from the top of the queues and
|
/// Remove the provided card from the top of the queues and
|
||||||
/// adjust the counts. If it was not at the top, return an error.
|
/// adjust the counts. If it was not at the top, return an error.
|
||||||
fn pop_entry(&mut self, id: CardId) -> Result<QueueEntry> {
|
fn pop_entry(&mut self, id: CardId) -> Result<QueueEntry> {
|
||||||
// This ignores the current cutoff, so may match if the provided
|
if let Some(pos) = self.intraday_learning.iter().position(|e| e.id == id) {
|
||||||
// learning card is not yet due. It should not happen in normal
|
let entry = self.intraday_learning.remove(pos).unwrap();
|
||||||
// practice, but does happen in the Python unit tests, as they answer
|
// FIXME:
|
||||||
// learning cards early.
|
// under normal circumstances this should not go below 0, but currently
|
||||||
if self
|
// the Python unit tests answer learning cards before they're due
|
||||||
.intraday_learning
|
self.counts.learning = self.counts.learning.saturating_sub(1);
|
||||||
.front()
|
Ok(entry.into())
|
||||||
.filter(|e| e.id == id)
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
Ok(self.pop_intraday_learning().unwrap().into())
|
|
||||||
} else if self.main.front().filter(|e| e.id == id).is_some() {
|
} else if self.main.front().filter(|e| e.id == id).is_some() {
|
||||||
Ok(self.pop_main().unwrap().into())
|
Ok(self.pop_main().unwrap().into())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue