mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
Reset filtered decks at import time
Before this change, filtered decks exported with scheduling remained filtered on import, and maybe_remove_from_filtered_deck() moved cards into them as their home deck, leading to errors during review. We may still want to provide a way to preserve filtered decks on import, but to do that we'll need to ensure we don't rewrite the home decks of cards, and we'll need to ensure the home decks are included as part of the import (or give an error if they're not). https://github.com/ankitects/anki/pull/1743/files#r839346423
This commit is contained in:
parent
23eda19677
commit
308c663233
2 changed files with 10 additions and 7 deletions
|
@ -9,7 +9,7 @@ use std::{
|
|||
use itertools::Itertools;
|
||||
|
||||
use crate::{
|
||||
decks::{immediate_parent_name, NormalDeck},
|
||||
decks::immediate_parent_name,
|
||||
io::filename_is_safe,
|
||||
latex::extract_latex,
|
||||
prelude::*,
|
||||
|
@ -89,11 +89,7 @@ impl ExchangeData {
|
|||
if let Ok(normal_mut) = deck.normal_mut() {
|
||||
normal_mut.config_id = 1;
|
||||
} else {
|
||||
// TODO: scheduling case
|
||||
deck.kind = DeckKind::Normal(NormalDeck {
|
||||
config_id: 1,
|
||||
..Default::default()
|
||||
})
|
||||
// filtered decks are reset at import time for legacy reasons
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +98,8 @@ impl ExchangeData {
|
|||
let mut position = col.get_next_card_position();
|
||||
for card in self.cards.iter_mut() {
|
||||
// schedule_as_new() removes cards from filtered decks, but we want to
|
||||
// leave cards in their current deck, and export filtered as regular decks
|
||||
// leave cards in their current deck, which gets converted to a regular
|
||||
// deck on import
|
||||
let deck_id = card.deck_id;
|
||||
if card.schedule_as_new(position, true, true) {
|
||||
position += 1;
|
||||
|
|
|
@ -64,6 +64,12 @@ impl DeckContext<'_> {
|
|||
}
|
||||
} else {
|
||||
self.ensure_valid_first_existing_parent(deck)?;
|
||||
if deck.is_filtered() {
|
||||
deck.kind = DeckKind::Normal(NormalDeck {
|
||||
config_id: 1,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
self.add_deck(deck)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue