From 95dea7f20a762be01e282d089be7e9b9c31c3b28 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 23 Mar 2021 18:40:50 +1000 Subject: [PATCH] move activeCols into config/ --- rslib/src/browser_rows.rs | 10 ++-------- rslib/src/config/mod.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/rslib/src/browser_rows.rs b/rslib/src/browser_rows.rs index 903700bb4..ec06ab182 100644 --- a/rslib/src/browser_rows.rs +++ b/rslib/src/browser_rows.rs @@ -78,14 +78,8 @@ fn card_render_required(columns: &[String]) -> bool { impl Collection { pub fn browser_row_for_card(&mut self, id: CardID) -> Result { - let columns: Vec = self.get_config_optional("activeCols").unwrap_or_else(|| { - vec![ - "noteFld".to_string(), - "template".to_string(), - "cardDue".to_string(), - "deck".to_string(), - ] - }); + // this is inefficient; we may want to use an enum in the future + let columns = self.get_desktop_browser_card_columns(); let mut context = RowContext::new(self, id, card_render_required(&columns))?; Ok(Row { diff --git a/rslib/src/config/mod.rs b/rslib/src/config/mod.rs index 12c0ced95..244013976 100644 --- a/rslib/src/config/mod.rs +++ b/rslib/src/config/mod.rs @@ -62,6 +62,9 @@ pub(crate) enum ConfigKey { NextNewCardPosition, #[strum(to_string = "schedVer")] SchedulerVersion, + + #[strum(to_string = "activeCols")] + DesktopBrowserCardColumns, } #[derive(PartialEq, Serialize_repr, Deserialize_repr, Clone, Copy, Debug)] @@ -129,6 +132,18 @@ impl Collection { self.get_config_default(ConfigKey::BrowserSortKind) } + pub(crate) fn get_desktop_browser_card_columns(&self) -> Vec { + self.get_config_optional(ConfigKey::DesktopBrowserCardColumns) + .unwrap_or_else(|| { + vec![ + "noteFld".to_string(), + "template".to_string(), + "cardDue".to_string(), + "deck".to_string(), + ] + }) + } + pub(crate) fn get_creation_utc_offset(&self) -> Option { self.get_config_optional(ConfigKey::CreationOffset) }