Split Col impls in decks in pub and private blocks

This commit is contained in:
RumovZ 2021-04-16 08:30:16 +02:00
parent 5931631d76
commit c03acf832b
4 changed files with 20 additions and 12 deletions

View file

@ -93,7 +93,9 @@ impl Collection {
deck.set_modified(usn);
self.add_or_update_single_deck_with_existing_id(&mut deck, usn)
}
}
impl Collection {
/// Add a single, normal deck with the provided name for a child deck.
/// Caller must have done necessarily validation on name.
fn add_parent_deck(&mut self, machine_name: &str, usn: Usn) -> Result<()> {

View file

@ -46,7 +46,9 @@ impl Collection {
}
Ok(card_count)
}
}
impl Collection {
fn delete_all_cards_in_normal_deck(&mut self, did: DeckId) -> Result<usize> {
let cids = self.storage.all_cards_in_single_deck(did)?;
self.remove_cards_and_orphaned_notes(&cids)?;

View file

@ -67,7 +67,9 @@ impl Collection {
Ok(())
}
}
impl Collection {
fn update_deck_stats_single<F>(
&mut self,
today: u32,

View file

@ -30,6 +30,20 @@ impl Collection {
}
}
pub(crate) fn remove_deck_and_add_grave_undoable(
&mut self,
deck: Deck,
usn: Usn,
) -> Result<()> {
self.state.deck_cache.clear();
self.add_deck_grave_undoable(deck.id, usn)?;
self.storage.remove_deck(deck.id)?;
self.save_undo(UndoableDeckChange::Removed(Box::new(deck)));
Ok(())
}
}
impl Collection {
pub(super) fn add_deck_undoable(&mut self, deck: &mut Deck) -> Result<(), AnkiError> {
self.storage.add_deck(deck)?;
self.save_undo(UndoableDeckChange::Added(Box::new(deck.clone())));
@ -59,18 +73,6 @@ impl Collection {
self.storage.update_deck(deck)
}
pub(crate) fn remove_deck_and_add_grave_undoable(
&mut self,
deck: Deck,
usn: Usn,
) -> Result<()> {
self.state.deck_cache.clear();
self.add_deck_grave_undoable(deck.id, usn)?;
self.storage.remove_deck(deck.id)?;
self.save_undo(UndoableDeckChange::Removed(Box::new(deck)));
Ok(())
}
fn restore_deleted_deck(&mut self, deck: Deck) -> Result<()> {
self.storage.add_or_update_deck_with_existing_id(&deck)?;
self.save_undo(UndoableDeckChange::Added(Box::new(deck)));