Add FutureDueShowBacklog as preferences

This commit is contained in:
Henrik Giesel 2021-01-27 01:15:19 +01:00
parent 322788133b
commit 677f4d340c
4 changed files with 17 additions and 4 deletions

View file

@ -1104,6 +1104,7 @@ message GraphPreferences {
Weekday calendar_first_day_of_week = 1; Weekday calendar_first_day_of_week = 1;
bool card_counts_separate_inactive = 2; bool card_counts_separate_inactive = 2;
bool browser_links_supported = 3; bool browser_links_supported = 3;
bool future_due_show_backlog = 4;
} }
message RevlogEntry { message RevlogEntry {

View file

@ -49,6 +49,7 @@ pub(crate) enum ConfigKey {
NewReviewMix, NewReviewMix,
FirstDayOfWeek, FirstDayOfWeek,
CardCountsSeparateInactive, CardCountsSeparateInactive,
FutureDueShowBacklog,
AnswerTimeLimitSecs, AnswerTimeLimitSecs,
ShowDayLearningCardsFirst, ShowDayLearningCardsFirst,
LastUnburiedDay, LastUnburiedDay,
@ -79,6 +80,7 @@ impl From<ConfigKey> for &'static str {
ConfigKey::NewReviewMix => "newSpread", ConfigKey::NewReviewMix => "newSpread",
ConfigKey::FirstDayOfWeek => "firstDayOfWeek", ConfigKey::FirstDayOfWeek => "firstDayOfWeek",
ConfigKey::CardCountsSeparateInactive => "cardCountsSeparateInactive", ConfigKey::CardCountsSeparateInactive => "cardCountsSeparateInactive",
ConfigKey::FutureDueShowBacklog => "futureDueShowBacklog",
ConfigKey::AnswerTimeLimitSecs => "timeLim", ConfigKey::AnswerTimeLimitSecs => "timeLim",
ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst", ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst",
ConfigKey::LastUnburiedDay => "lastUnburied", ConfigKey::LastUnburiedDay => "lastUnburied",
@ -249,6 +251,15 @@ impl Collection {
self.set_config(ConfigKey::CardCountsSeparateInactive, &separate) 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 { pub(crate) fn get_show_due_counts(&self) -> bool {
self.get_config_optional(ConfigKey::ShowRemainingDueCountsInStudy) self.get_config_optional(ConfigKey::ShowRemainingDueCountsInStudy)
.unwrap_or(true) .unwrap_or(true)

View file

@ -52,6 +52,7 @@ impl Collection {
calendar_first_day_of_week: self.get_first_day_of_week() as i32, calendar_first_day_of_week: self.get_first_day_of_week() as i32,
card_counts_separate_inactive: self.get_card_counts_separate_inactive(), card_counts_separate_inactive: self.get_card_counts_separate_inactive(),
browser_links_supported: true, browser_links_supported: true,
future_due_show_backlog: self.get_future_due_show_backlog(),
}) })
} }
@ -63,6 +64,7 @@ impl Collection {
_ => Weekday::Sunday, _ => Weekday::Sunday,
})?; })?;
self.set_card_counts_separate_inactive(prefs.card_counts_separate_inactive)?; self.set_card_counts_separate_inactive(prefs.card_counts_separate_inactive)?;
self.set_future_due_show_backlog(prefs.future_due_show_backlog)?;
Ok(()) Ok(())
} }
} }

View file

@ -21,9 +21,8 @@
let graphData = null as GraphData | null; let graphData = null as GraphData | null;
let histogramData = null as HistogramData | null; let histogramData = null as HistogramData | null;
let tableData: TableDatum[] = [] as any; let tableData: TableDatum[] = [] as any;
let backlog: boolean = true;
let graphRange: GraphRange = GraphRange.Month; let graphRange: GraphRange = GraphRange.Month;
let { browserLinksSupported } = preferences; let { browserLinksSupported, futureDueShowBacklog } = preferences;
$: if (sourceData) { $: if (sourceData) {
graphData = gatherData(sourceData); graphData = gatherData(sourceData);
@ -33,7 +32,7 @@
({ histogramData, tableData } = buildHistogram( ({ histogramData, tableData } = buildHistogram(
graphData, graphData,
graphRange, graphRange,
backlog, $futureDueShowBacklog,
i18n, i18n,
dispatch, dispatch,
$browserLinksSupported $browserLinksSupported
@ -53,7 +52,7 @@
<div class="range-box-inner"> <div class="range-box-inner">
{#if graphData && graphData.haveBacklog} {#if graphData && graphData.haveBacklog}
<label> <label>
<input type="checkbox" bind:checked={backlog} /> <input type="checkbox" bind:checked={$futureDueShowBacklog} />
{backlogLabel} {backlogLabel}
</label> </label>
{/if} {/if}