Uniformly rename firstWeekday to firstDayOfWeek

This commit is contained in:
Henrik Giesel 2021-01-22 16:53:33 +01:00
parent b0c2e8c99c
commit aebaa04652
4 changed files with 18 additions and 17 deletions

View file

@ -1084,12 +1084,6 @@ message GraphsIn {
}
message GraphsOut {
enum Weekday {
SUNDAY = 0;
MONDAY = 1;
FRIDAY = 5;
SATURDAY = 6;
}
repeated Card cards = 1;
repeated RevlogEntry revlog = 2;
uint32 days_elapsed = 3;
@ -1098,7 +1092,6 @@ message GraphsOut {
uint32 scheduler_version = 5;
/// Seconds to add to UTC timestamps to get local time.
int32 local_offset_secs = 7;
Weekday first_weekday = 8;
}
message GraphsPreferencesOut {

View file

@ -47,7 +47,7 @@ pub(crate) enum ConfigKey {
ShowRemainingDueCountsInStudy,
ShowIntervalsAboveAnswerButtons,
NewReviewMix,
FirstWeekday,
FirstDayOfWeek,
AnswerTimeLimitSecs,
ShowDayLearningCardsFirst,
LastUnburiedDay,
@ -76,7 +76,7 @@ impl From<ConfigKey> for &'static str {
ConfigKey::ShowRemainingDueCountsInStudy => "dueCounts",
ConfigKey::ShowIntervalsAboveAnswerButtons => "estTimes",
ConfigKey::NewReviewMix => "newSpread",
ConfigKey::FirstWeekday => "firstWeekday",
ConfigKey::FirstDayOfWeek => "firstDayOfWeek",
ConfigKey::AnswerTimeLimitSecs => "timeLim",
ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst",
ConfigKey::LastUnburiedDay => "lastUnburied",
@ -229,11 +229,15 @@ impl Collection {
self.set_config(ConfigKey::NewReviewMix, &(mix as u8))
}
pub(crate) fn get_first_weekday(&self) -> Weekday {
self.get_config_optional(ConfigKey::FirstWeekday)
pub(crate) fn get_first_day_of_week(&self) -> Weekday {
self.get_config_optional(ConfigKey::FirstDayOfWeek)
.unwrap_or(Weekday::Sunday)
}
pub(crate) fn set_first_day_of_week(&self, weekday: Weekday) -> Result<()> {
self.set_config(ConfigKey::FirstDayOfWeek, &weekday)
}
pub(crate) fn get_show_due_counts(&self) -> bool {
self.get_config_optional(ConfigKey::ShowRemainingDueCountsInStudy)
.unwrap_or(true)

View file

@ -1,7 +1,7 @@
// 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};
use crate::{backend_proto as pb, prelude::*, revlog::RevlogEntry, search::SortMode, config::Weekday};
impl Collection {
pub(crate) fn graph_data_for_search(
@ -42,19 +42,23 @@ impl Collection {
next_day_at_secs: timing.next_day_at as u32,
scheduler_version: self.sched_ver() as u32,
local_offset_secs: local_offset_secs as i32,
first_weekday: self.get_first_weekday() as i32,
})
}
pub(crate) fn graphs_preferences(&self) -> Result<pb::GraphsPreferencesOut> {
Ok(pb::GraphsPreferencesOut {
calendar_first_day_of_week: self.get_first_weekday() as i32,
calendar_first_day_of_week: self.get_first_day_of_week() as i32,
card_counts_separate_inactive: true,
})
}
pub(crate) fn set_graphs_preferences(&self, prefs: pb::GraphsPreferencesOut) -> Result<()> {
// self.set_first_weekday(prefs.calendar_first_day_of_week);
self.set_first_day_of_week(match prefs.calendar_first_day_of_week {
1 => Weekday::Monday,
5 => Weekday::Friday,
6 => Weekday::Saturday,
_ => Weekday::Sunday,
})?;
Ok(())
}
}

View file

@ -64,9 +64,9 @@ export function gatherData(
const timeFunction =
firstDayOfWeek === Weekday.MONDAY
? timeMonday
: data.firstWeekday === Weekday.FRIDAY
: firstDayOfWeek === Weekday.FRIDAY
? timeFriday
: data.firstWeekday === Weekday.SATURDAY
: firstDayOfWeek === Weekday.SATURDAY
? timeSaturday
: timeSunday;