From cdc781e17f242d7fe342ff5d78c64130828cf2b9 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Sat, 9 Jul 2022 22:13:36 +0200 Subject: [PATCH] Export deck limits when exporting with scheduling --- pylib/anki/exporting.py | 1 + rslib/src/import_export/gather.rs | 6 ++++-- rslib/src/import_export/package/apkg/import/decks.rs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pylib/anki/exporting.py b/pylib/anki/exporting.py index dbfbc44b0..651207b9b 100644 --- a/pylib/anki/exporting.py +++ b/pylib/anki/exporting.py @@ -270,6 +270,7 @@ class AnkiExporter(Exporter): # scheduling not included, so reset deck settings to default d = dict(d) d["conf"] = 1 + d["reviewLimit"] = d["newLimit"] = None self.dst.decks.update(d) # copy used deck confs for dc in self.src.decks.all_config(): diff --git a/rslib/src/import_export/gather.rs b/rslib/src/import_export/gather.rs index b73de1bba..ac415008c 100644 --- a/rslib/src/import_export/gather.rs +++ b/rslib/src/import_export/gather.rs @@ -77,7 +77,7 @@ impl ExchangeData { fn remove_scheduling_information(&mut self, col: &Collection) { self.remove_system_tags(); - self.reset_deck_config_ids(); + self.reset_deck_config_ids_and_limits(); self.reset_cards(col); } @@ -91,10 +91,12 @@ impl ExchangeData { } } - fn reset_deck_config_ids(&mut self) { + fn reset_deck_config_ids_and_limits(&mut self) { for deck in self.decks.iter_mut() { if let Ok(normal_mut) = deck.normal_mut() { normal_mut.config_id = 1; + normal_mut.review_limit = None; + normal_mut.new_limit = None; } else { // filtered decks are reset at import time for legacy reasons } diff --git a/rslib/src/import_export/package/apkg/import/decks.rs b/rslib/src/import_export/package/apkg/import/decks.rs index c9717963f..0e6754c19 100644 --- a/rslib/src/import_export/package/apkg/import/decks.rs +++ b/rslib/src/import_export/package/apkg/import/decks.rs @@ -163,6 +163,8 @@ impl NormalDeck { if other.config_id != 1 { self.config_id = other.config_id; } + self.review_limit = other.review_limit.or(self.review_limit); + self.new_limit = other.new_limit.or(self.new_limit); } }