move activeCols into config/

This commit is contained in:
Damien Elmes 2021-03-23 18:40:50 +10:00
parent 5fd79d9246
commit 95dea7f20a
2 changed files with 17 additions and 8 deletions

View File

@ -78,14 +78,8 @@ fn card_render_required(columns: &[String]) -> bool {
impl Collection {
pub fn browser_row_for_card(&mut self, id: CardID) -> Result<Row> {
let columns: Vec<String> = 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 {

View File

@ -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<String> {
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<i32> {
self.get_config_optional(ConfigKey::CreationOffset)
}