mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
modify generate_cards_for_note
to return count
This commit is contained in:
parent
8ef208e418
commit
95d7445ff6
1 changed files with 7 additions and 5 deletions
|
@ -215,7 +215,7 @@ impl Collection {
|
||||||
ctx: &CardGenContext<impl Deref<Target = Notetype>>,
|
ctx: &CardGenContext<impl Deref<Target = Notetype>>,
|
||||||
note: &Note,
|
note: &Note,
|
||||||
target_deck_id: DeckId,
|
target_deck_id: DeckId,
|
||||||
) -> Result<()> {
|
) -> Result<usize> {
|
||||||
self.generate_cards_for_note(
|
self.generate_cards_for_note(
|
||||||
ctx,
|
ctx,
|
||||||
note,
|
note,
|
||||||
|
@ -231,7 +231,8 @@ impl Collection {
|
||||||
note: &Note,
|
note: &Note,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let existing = self.storage.existing_cards_for_note(note.id)?;
|
let existing = self.storage.existing_cards_for_note(note.id)?;
|
||||||
self.generate_cards_for_note(ctx, note, &existing, ctx.last_deck, &mut Default::default())
|
self.generate_cards_for_note(ctx, note, &existing, ctx.last_deck, &mut Default::default())?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_cards_for_note(
|
fn generate_cards_for_note(
|
||||||
|
@ -241,12 +242,13 @@ impl Collection {
|
||||||
existing: &[AlreadyGeneratedCardInfo],
|
existing: &[AlreadyGeneratedCardInfo],
|
||||||
target_deck_id: Option<DeckId>,
|
target_deck_id: Option<DeckId>,
|
||||||
cache: &mut CardGenCache,
|
cache: &mut CardGenCache,
|
||||||
) -> Result<()> {
|
) -> Result<usize> {
|
||||||
let cards = ctx.new_cards_required(note, existing, true);
|
let cards = ctx.new_cards_required(note, existing, true);
|
||||||
if cards.is_empty() {
|
if cards.is_empty() {
|
||||||
return Ok(());
|
return Ok(0);
|
||||||
}
|
}
|
||||||
self.add_generated_cards(note.id, &cards, target_deck_id, cache)
|
self.add_generated_cards(note.id, &cards, target_deck_id, cache)?;
|
||||||
|
Ok(cards.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn generate_cards_for_notetype(
|
pub(crate) fn generate_cards_for_notetype(
|
||||||
|
|
Loading…
Reference in a new issue