mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Uniformly rename firstWeekday to firstDayOfWeek
This commit is contained in:
parent
b0c2e8c99c
commit
aebaa04652
4 changed files with 18 additions and 17 deletions
|
@ -1084,12 +1084,6 @@ message GraphsIn {
|
||||||
}
|
}
|
||||||
|
|
||||||
message GraphsOut {
|
message GraphsOut {
|
||||||
enum Weekday {
|
|
||||||
SUNDAY = 0;
|
|
||||||
MONDAY = 1;
|
|
||||||
FRIDAY = 5;
|
|
||||||
SATURDAY = 6;
|
|
||||||
}
|
|
||||||
repeated Card cards = 1;
|
repeated Card cards = 1;
|
||||||
repeated RevlogEntry revlog = 2;
|
repeated RevlogEntry revlog = 2;
|
||||||
uint32 days_elapsed = 3;
|
uint32 days_elapsed = 3;
|
||||||
|
@ -1098,7 +1092,6 @@ message GraphsOut {
|
||||||
uint32 scheduler_version = 5;
|
uint32 scheduler_version = 5;
|
||||||
/// Seconds to add to UTC timestamps to get local time.
|
/// Seconds to add to UTC timestamps to get local time.
|
||||||
int32 local_offset_secs = 7;
|
int32 local_offset_secs = 7;
|
||||||
Weekday first_weekday = 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GraphsPreferencesOut {
|
message GraphsPreferencesOut {
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub(crate) enum ConfigKey {
|
||||||
ShowRemainingDueCountsInStudy,
|
ShowRemainingDueCountsInStudy,
|
||||||
ShowIntervalsAboveAnswerButtons,
|
ShowIntervalsAboveAnswerButtons,
|
||||||
NewReviewMix,
|
NewReviewMix,
|
||||||
FirstWeekday,
|
FirstDayOfWeek,
|
||||||
AnswerTimeLimitSecs,
|
AnswerTimeLimitSecs,
|
||||||
ShowDayLearningCardsFirst,
|
ShowDayLearningCardsFirst,
|
||||||
LastUnburiedDay,
|
LastUnburiedDay,
|
||||||
|
@ -76,7 +76,7 @@ impl From<ConfigKey> for &'static str {
|
||||||
ConfigKey::ShowRemainingDueCountsInStudy => "dueCounts",
|
ConfigKey::ShowRemainingDueCountsInStudy => "dueCounts",
|
||||||
ConfigKey::ShowIntervalsAboveAnswerButtons => "estTimes",
|
ConfigKey::ShowIntervalsAboveAnswerButtons => "estTimes",
|
||||||
ConfigKey::NewReviewMix => "newSpread",
|
ConfigKey::NewReviewMix => "newSpread",
|
||||||
ConfigKey::FirstWeekday => "firstWeekday",
|
ConfigKey::FirstDayOfWeek => "firstDayOfWeek",
|
||||||
ConfigKey::AnswerTimeLimitSecs => "timeLim",
|
ConfigKey::AnswerTimeLimitSecs => "timeLim",
|
||||||
ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst",
|
ConfigKey::ShowDayLearningCardsFirst => "dayLearnFirst",
|
||||||
ConfigKey::LastUnburiedDay => "lastUnburied",
|
ConfigKey::LastUnburiedDay => "lastUnburied",
|
||||||
|
@ -229,11 +229,15 @@ impl Collection {
|
||||||
self.set_config(ConfigKey::NewReviewMix, &(mix as u8))
|
self.set_config(ConfigKey::NewReviewMix, &(mix as u8))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_first_weekday(&self) -> Weekday {
|
pub(crate) fn get_first_day_of_week(&self) -> Weekday {
|
||||||
self.get_config_optional(ConfigKey::FirstWeekday)
|
self.get_config_optional(ConfigKey::FirstDayOfWeek)
|
||||||
.unwrap_or(Weekday::Sunday)
|
.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 {
|
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)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// 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 {
|
impl Collection {
|
||||||
pub(crate) fn graph_data_for_search(
|
pub(crate) fn graph_data_for_search(
|
||||||
|
@ -42,19 +42,23 @@ impl Collection {
|
||||||
next_day_at_secs: timing.next_day_at as u32,
|
next_day_at_secs: timing.next_day_at as u32,
|
||||||
scheduler_version: self.sched_ver() as u32,
|
scheduler_version: self.sched_ver() as u32,
|
||||||
local_offset_secs: local_offset_secs as i32,
|
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> {
|
pub(crate) fn graphs_preferences(&self) -> Result<pb::GraphsPreferencesOut> {
|
||||||
Ok(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,
|
card_counts_separate_inactive: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_graphs_preferences(&self, prefs: pb::GraphsPreferencesOut) -> Result<()> {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,9 @@ export function gatherData(
|
||||||
const timeFunction =
|
const timeFunction =
|
||||||
firstDayOfWeek === Weekday.MONDAY
|
firstDayOfWeek === Weekday.MONDAY
|
||||||
? timeMonday
|
? timeMonday
|
||||||
: data.firstWeekday === Weekday.FRIDAY
|
: firstDayOfWeek === Weekday.FRIDAY
|
||||||
? timeFriday
|
? timeFriday
|
||||||
: data.firstWeekday === Weekday.SATURDAY
|
: firstDayOfWeek === Weekday.SATURDAY
|
||||||
? timeSaturday
|
? timeSaturday
|
||||||
: timeSunday;
|
: timeSunday;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue