diff --git a/rslib/src/config.rs b/rslib/src/config.rs index eb2b88b1a..c76147100 100644 --- a/rslib/src/config.rs +++ b/rslib/src/config.rs @@ -48,6 +48,7 @@ pub(crate) enum ConfigKey { ShowIntervalsAboveAnswerButtons, NewReviewMix, FirstDayOfWeek, + CardCountsSeparateInactive, AnswerTimeLimitSecs, ShowDayLearningCardsFirst, LastUnburiedDay, @@ -77,6 +78,7 @@ impl From for &'static str { ConfigKey::ShowIntervalsAboveAnswerButtons => "estTimes", ConfigKey::NewReviewMix => "newSpread", ConfigKey::FirstDayOfWeek => "firstDayOfWeek", + ConfigKey::CardCountsSeparateInactive => "cardCountsSeparateInactive", ConfigKey::AnswerTimeLimitSecs => "timeLim", ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst", ConfigKey::LastUnburiedDay => "lastUnburied", @@ -238,6 +240,15 @@ impl Collection { self.set_config(ConfigKey::FirstDayOfWeek, &weekday) } + pub(crate) fn get_card_counts_separate_inactive(&self) -> bool { + self.get_config_optional(ConfigKey::CardCountsSeparateInactive) + .unwrap_or(true) + } + + pub(crate) fn set_card_counts_separate_inactive(&self, separate: bool) -> Result<()> { + self.set_config(ConfigKey::CardCountsSeparateInactive, &separate) + } + 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 dcfe4a2a3..ed4a73eda 100644 --- a/rslib/src/stats/graphs.rs +++ b/rslib/src/stats/graphs.rs @@ -1,7 +1,9 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -use crate::{backend_proto as pb, prelude::*, revlog::RevlogEntry, search::SortMode, config::Weekday}; +use crate::{ + backend_proto as pb, config::Weekday, prelude::*, revlog::RevlogEntry, search::SortMode, +}; impl Collection { pub(crate) fn graph_data_for_search( @@ -48,7 +50,7 @@ impl Collection { pub(crate) fn graphs_preferences(&self) -> Result { Ok(pb::GraphsPreferencesOut { calendar_first_day_of_week: self.get_first_day_of_week() as i32, - card_counts_separate_inactive: true, + card_counts_separate_inactive: self.get_card_counts_separate_inactive(), }) } @@ -59,6 +61,7 @@ impl Collection { 6 => Weekday::Saturday, _ => Weekday::Sunday, })?; + self.set_card_counts_separate_inactive(prefs.card_counts_separate_inactive)?; Ok(()) } } diff --git a/ts/graphs/CalendarGraph.svelte b/ts/graphs/CalendarGraph.svelte index 6b43590da..8e88cdf55 100644 --- a/ts/graphs/CalendarGraph.svelte +++ b/ts/graphs/CalendarGraph.svelte @@ -52,8 +52,8 @@ i18n, nightMode, revlogRange, - calendarFirstDayOfWeek.set, - ) + calendarFirstDayOfWeek.set + ); } const title = i18n.tr(i18n.TR.STATISTICS_CALENDAR_TITLE); diff --git a/ts/graphs/calendar.ts b/ts/graphs/calendar.ts index 62957bcad..142d56763 100644 --- a/ts/graphs/calendar.ts +++ b/ts/graphs/calendar.ts @@ -86,7 +86,7 @@ export function renderCalendar( i18n: I18n, nightMode: boolean, revlogRange: RevlogRange, - setFirstDayOfWeek: (d: number) => void, + setFirstDayOfWeek: (d: number) => void ): void { const svg = select(svgElem); const now = new Date(); @@ -184,7 +184,11 @@ export function renderCalendar( .attr("font-family", "monospace") .style("user-select", "none") .on("click", null) - .filter((d: number) => [Weekday.SUNDAY, Weekday.MONDAY, Weekday.FRIDAY, Weekday.SATURDAY].includes(d)) + .filter((d: number) => + [Weekday.SUNDAY, Weekday.MONDAY, Weekday.FRIDAY, Weekday.SATURDAY].includes( + d + ) + ) .on("click", setFirstDayOfWeek); svg.select("g.days") @@ -203,5 +207,5 @@ export function renderCalendar( .on("mouseout", hideTooltip) .transition() .duration(800) - .attr("fill", (d) => d.count === 0 ? emptyColour : blues(d.count)!); + .attr("fill", (d) => (d.count === 0 ? emptyColour : blues(d.count)!)); }