mirror of
https://github.com/ankitects/anki.git
synced 2026-01-08 03:23:54 -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
|
||||
/// adjust the counts. If it was not at the top, return an error.
|
||||
fn pop_entry(&mut self, id: CardId) -> Result<QueueEntry> {
|
||||
// This ignores the current cutoff, so may match if the provided
|
||||
// learning card is not yet due. It should not happen in normal
|
||||
// practice, but does happen in the Python unit tests, as they answer
|
||||
// learning cards early.
|
||||
if self
|
||||
.intraday_learning
|
||||
.front()
|
||||
.filter(|e| e.id == id)
|
||||
.is_some()
|
||||
{
|
||||
Ok(self.pop_intraday_learning().unwrap().into())
|
||||
if let Some(pos) = self.intraday_learning.iter().position(|e| e.id == id) {
|
||||
let entry = self.intraday_learning.remove(pos).unwrap();
|
||||
// FIXME:
|
||||
// under normal circumstances this should not go below 0, but currently
|
||||
// the Python unit tests answer learning cards before they're due
|
||||
self.counts.learning = self.counts.learning.saturating_sub(1);
|
||||
Ok(entry.into())
|
||||
} else if self.main.front().filter(|e| e.id == id).is_some() {
|
||||
Ok(self.pop_main().unwrap().into())
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue