From 677f4d340c11a19ce9bd43d6998f0d3c16ee4b45 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Wed, 27 Jan 2021 01:15:19 +0100 Subject: [PATCH] Add FutureDueShowBacklog as preferences --- rslib/backend.proto | 1 + rslib/src/config.rs | 11 +++++++++++ rslib/src/stats/graphs.rs | 2 ++ ts/graphs/FutureDue.svelte | 7 +++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/rslib/backend.proto b/rslib/backend.proto index 1dcb9dac5..93c1a3990 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -1104,6 +1104,7 @@ message GraphPreferences { Weekday calendar_first_day_of_week = 1; bool card_counts_separate_inactive = 2; bool browser_links_supported = 3; + bool future_due_show_backlog = 4; } message RevlogEntry { diff --git a/rslib/src/config.rs b/rslib/src/config.rs index c76147100..5d3dde251 100644 --- a/rslib/src/config.rs +++ b/rslib/src/config.rs @@ -49,6 +49,7 @@ pub(crate) enum ConfigKey { NewReviewMix, FirstDayOfWeek, CardCountsSeparateInactive, + FutureDueShowBacklog, AnswerTimeLimitSecs, ShowDayLearningCardsFirst, LastUnburiedDay, @@ -79,6 +80,7 @@ impl From for &'static str { ConfigKey::NewReviewMix => "newSpread", ConfigKey::FirstDayOfWeek => "firstDayOfWeek", ConfigKey::CardCountsSeparateInactive => "cardCountsSeparateInactive", + ConfigKey::FutureDueShowBacklog => "futureDueShowBacklog", ConfigKey::AnswerTimeLimitSecs => "timeLim", ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst", ConfigKey::LastUnburiedDay => "lastUnburied", @@ -249,6 +251,15 @@ impl Collection { self.set_config(ConfigKey::CardCountsSeparateInactive, &separate) } + pub(crate) fn get_future_due_show_backlog(&self) -> bool { + self.get_config_optional(ConfigKey::FutureDueShowBacklog) + .unwrap_or(true) + } + + pub(crate) fn set_future_due_show_backlog(&self, show: bool) -> Result<()> { + self.set_config(ConfigKey::FutureDueShowBacklog, &show) + } + pub(crate) fn get_show_due_counts(&self) -> bool { self.get_config_optional(ConfigKey::ShowRemainingDueCountsInStudy) .unwrap_or(true) diff --git a/rslib/src/stats/graphs.rs b/rslib/src/stats/graphs.rs index 704625575..65e9387a0 100644 --- a/rslib/src/stats/graphs.rs +++ b/rslib/src/stats/graphs.rs @@ -52,6 +52,7 @@ impl Collection { calendar_first_day_of_week: self.get_first_day_of_week() as i32, card_counts_separate_inactive: self.get_card_counts_separate_inactive(), browser_links_supported: true, + future_due_show_backlog: self.get_future_due_show_backlog(), }) } @@ -63,6 +64,7 @@ impl Collection { _ => Weekday::Sunday, })?; self.set_card_counts_separate_inactive(prefs.card_counts_separate_inactive)?; + self.set_future_due_show_backlog(prefs.future_due_show_backlog)?; Ok(()) } } diff --git a/ts/graphs/FutureDue.svelte b/ts/graphs/FutureDue.svelte index e7b504eda..6401fdf9c 100644 --- a/ts/graphs/FutureDue.svelte +++ b/ts/graphs/FutureDue.svelte @@ -21,9 +21,8 @@ let graphData = null as GraphData | null; let histogramData = null as HistogramData | null; let tableData: TableDatum[] = [] as any; - let backlog: boolean = true; let graphRange: GraphRange = GraphRange.Month; - let { browserLinksSupported } = preferences; + let { browserLinksSupported, futureDueShowBacklog } = preferences; $: if (sourceData) { graphData = gatherData(sourceData); @@ -33,7 +32,7 @@ ({ histogramData, tableData } = buildHistogram( graphData, graphRange, - backlog, + $futureDueShowBacklog, i18n, dispatch, $browserLinksSupported @@ -53,7 +52,7 @@
{#if graphData && graphData.haveBacklog} {/if}