handle error of evaluation if items.is_empty()

This commit is contained in:
Jarrett Ye 2024-04-14 17:08:49 +08:00
parent e269983150
commit 7f0a5570e7
No known key found for this signature in database
GPG key ID: EBFC55E0C1A352BB
2 changed files with 5 additions and 0 deletions

View file

@ -162,6 +162,9 @@ impl Collection {
.get_revlog_entries_for_searched_cards_in_card_order()?;
let (items, review_count) =
fsrs_items_for_training(revlogs, timing.next_day_at, ignore_revlogs_before);
if items.is_empty() {
return Err(AnkiError::FsrsInsufficientData);
}
anki_progress.state.reviews = review_count as u32;
let fsrs = FSRS::new(Some(weights))?;
Ok(fsrs.evaluate(items, |ip| {

View file

@ -185,6 +185,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
},
);
} catch (err) {
alert(tr.deckConfigNotEnoughHistory());
} finally {
checkingWeights = false;
}