diff --git a/rslib/src/notes.rs b/rslib/src/notes.rs index 52b8529f8..c4e3226c7 100644 --- a/rslib/src/notes.rs +++ b/rslib/src/notes.rs @@ -179,6 +179,7 @@ mod test { use super::{anki_base91, field_checksum}; use crate::{ collection::open_test_collection, + decks::DeckID, err::{AnkiError, Result}, search::SortMode, }; @@ -226,9 +227,7 @@ mod test { let existing = col.storage.existing_cards_for_note(note.id)?; assert_eq!(existing.len(), 1); assert_eq!(existing[0].ord, 0); - - // fixme - // assert_eq!(existing[0].original_deck_id, DeckID(1)); + assert_eq!(existing[0].original_deck_id, DeckID(1)); note.fields[0] = "{{c1::foo}} {{c2::bar}} {{c3::baz}} {{c0::quux}} {{c501::over}}".into(); col.update_note(&mut note)?; diff --git a/rslib/src/notetype/cardgen.rs b/rslib/src/notetype/cardgen.rs index af9169472..f492c1def 100644 --- a/rslib/src/notetype/cardgen.rs +++ b/rslib/src/notetype/cardgen.rs @@ -239,6 +239,7 @@ impl Collection { ) -> Result<()> { let mut next_pos = None; for c in cards { + // fixme: deal with case where invalid deck pointed to let did = c.did.unwrap_or_else(|| ctx.notetype.target_deck_id()); let due = c.due.unwrap_or_else(|| { if next_pos.is_none() { @@ -253,6 +254,3 @@ impl Collection { Ok(()) } } - -// fixme: deal with case where invalid deck pointed to -// fixme: make sure we don't orphan notes diff --git a/rslib/src/notetype/mod.rs b/rslib/src/notetype/mod.rs index 1f91f1aaa..14ba42af2 100644 --- a/rslib/src/notetype/mod.rs +++ b/rslib/src/notetype/mod.rs @@ -167,6 +167,8 @@ impl NoteType { } pub(crate) fn prepare_for_adding(&mut self) { + // defaults to 0 + self.config.target_deck_id = 1; self.normalize_names(); self.ensure_names_unique(); self.update_requirements(); diff --git a/rslib/src/notetype/schemachange.rs b/rslib/src/notetype/schemachange.rs index 602b9ceb5..5a5241a45 100644 --- a/rslib/src/notetype/schemachange.rs +++ b/rslib/src/notetype/schemachange.rs @@ -239,3 +239,6 @@ mod test { Ok(()) } } + + +// fixme: make sure we don't orphan notes