make config prefix removal undoable

This commit is contained in:
Damien Elmes 2021-04-29 19:16:02 +10:00
parent 610f0b5254
commit 57eab0e33d
3 changed files with 4 additions and 4 deletions

View file

@ -19,7 +19,7 @@ impl DeckConfigKey {
} }
impl Collection { impl Collection {
pub(crate) fn clear_aux_config_for_deck(&self, ntid: DeckId) -> Result<()> { pub(crate) fn clear_aux_config_for_deck(&mut self, ntid: DeckId) -> Result<()> {
self.remove_config_prefix(&build_aux_deck_key(ntid, "")) self.remove_config_prefix(&build_aux_deck_key(ntid, ""))
} }

View file

@ -117,9 +117,9 @@ impl Collection {
} }
/// Remove all keys starting with provided prefix, which must end with '_'. /// Remove all keys starting with provided prefix, which must end with '_'.
pub(crate) fn remove_config_prefix(&self, key: &str) -> Result<()> { pub(crate) fn remove_config_prefix(&mut self, key: &str) -> Result<()> {
for (key, _val) in self.storage.get_config_prefix(key)? { for (key, _val) in self.storage.get_config_prefix(key)? {
self.storage.remove_config(&key)?; self.remove_config(key.as_str())?;
} }
Ok(()) Ok(())
} }

View file

@ -33,7 +33,7 @@ impl Collection {
.map(|_| ()) .map(|_| ())
} }
pub(crate) fn clear_aux_config_for_notetype(&self, ntid: NotetypeId) -> Result<()> { pub(crate) fn clear_aux_config_for_notetype(&mut self, ntid: NotetypeId) -> Result<()> {
self.remove_config_prefix(&build_aux_notetype_key(ntid, "")) self.remove_config_prefix(&build_aux_notetype_key(ntid, ""))
} }