use default deck for new note types

This commit is contained in:
Damien Elmes 2020-04-21 14:24:19 +10:00
parent 15ff279a96
commit 5c3e5c672f
4 changed files with 8 additions and 6 deletions

View File

@ -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)?;

View File

@ -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

View File

@ -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();

View File

@ -239,3 +239,6 @@ mod test {
Ok(())
}
}
// fixme: make sure we don't orphan notes