diff --git a/pylib/tools/genbackend.py b/pylib/tools/genbackend.py index 4a2c75e06..3074bde63 100755 --- a/pylib/tools/genbackend.py +++ b/pylib/tools/genbackend.py @@ -34,7 +34,7 @@ LABEL_REPEATED = 3 # messages we don't want to unroll in codegen SKIP_UNROLL_INPUT = {"TranslateString"} -SKIP_DECODE = {"Graphs", "GetGraphsPreferences"} +SKIP_DECODE = {"Graphs", "GetGraphPreferences"} def python_type(field): diff --git a/qt/aqt/mediasrv.py b/qt/aqt/mediasrv.py index 94082814b..5482b849f 100644 --- a/qt/aqt/mediasrv.py +++ b/qt/aqt/mediasrv.py @@ -257,13 +257,13 @@ def graph_data() -> bytes: def graph_preferences() -> bytes: - return aqt.mw.col.backend.get_graphs_preferences() + return aqt.mw.col.backend.get_graph_preferences() def set_graph_preferences() -> None: - input = pb.GraphsPreferences() + input = pb.GraphPreferences() input.ParseFromString(request.data) - aqt.mw.col.backend.set_graphs_preferences(input=input) + aqt.mw.col.backend.set_graph_preferences(input=input) def congrats_info() -> bytes: diff --git a/rslib/backend.proto b/rslib/backend.proto index 3f2e74f14..56d38dd96 100644 --- a/rslib/backend.proto +++ b/rslib/backend.proto @@ -116,8 +116,8 @@ service BackendService { rpc CardStats(CardID) returns (String); rpc Graphs(GraphsIn) returns (GraphsOut); - rpc GetGraphsPreferences(Empty) returns (GraphsPreferences); - rpc SetGraphsPreferences(GraphsPreferences) returns (Empty); + rpc GetGraphPreferences(Empty) returns (GraphPreferences); + rpc SetGraphPreferences(GraphPreferences) returns (Empty); // media @@ -1094,7 +1094,7 @@ message GraphsOut { int32 local_offset_secs = 7; } -message GraphsPreferences { +message GraphPreferences { enum Weekday { SUNDAY = 0; MONDAY = 1; diff --git a/rslib/src/backend/mod.rs b/rslib/src/backend/mod.rs index d502f9f8b..71e1595de 100644 --- a/rslib/src/backend/mod.rs +++ b/rslib/src/backend/mod.rs @@ -676,12 +676,12 @@ impl BackendService for Backend { self.with_col(|col| col.graph_data_for_search(&input.search, input.days)) } - fn get_graphs_preferences(&self, _input: pb::Empty) -> BackendResult { - self.with_col(|col| col.get_graphs_preferences()) + fn get_graph_preferences(&self, _input: pb::Empty) -> BackendResult { + self.with_col(|col| col.get_graph_preferences()) } - fn set_graphs_preferences(&self, input: pb::GraphsPreferences) -> BackendResult { - self.with_col(|col| col.set_graphs_preferences(input)) + fn set_graph_preferences(&self, input: pb::GraphPreferences) -> BackendResult { + self.with_col(|col| col.set_graph_preferences(input)) .map(Into::into) } diff --git a/rslib/src/stats/graphs.rs b/rslib/src/stats/graphs.rs index bf4c6d62b..093aecb73 100644 --- a/rslib/src/stats/graphs.rs +++ b/rslib/src/stats/graphs.rs @@ -47,14 +47,14 @@ impl Collection { }) } - pub(crate) fn get_graphs_preferences(&self) -> Result { - Ok(pb::GraphsPreferences { + pub(crate) fn get_graph_preferences(&self) -> Result { + Ok(pb::GraphPreferences { calendar_first_day_of_week: self.get_first_day_of_week() as i32, card_counts_separate_inactive: self.get_card_counts_separate_inactive(), }) } - pub(crate) fn set_graphs_preferences(&self, prefs: pb::GraphsPreferences) -> Result<()> { + pub(crate) fn set_graph_preferences(&self, prefs: pb::GraphPreferences) -> Result<()> { self.set_first_day_of_week(match prefs.calendar_first_day_of_week { 1 => Weekday::Monday, 5 => Weekday::Friday, diff --git a/ts/graphs/calendar.ts b/ts/graphs/calendar.ts index 5f080fdab..b933ca411 100644 --- a/ts/graphs/calendar.ts +++ b/ts/graphs/calendar.ts @@ -41,8 +41,8 @@ interface DayDatum { date: Date; } -type WeekdayType = pb.BackendProto.GraphsPreferences.Weekday; -const Weekday = pb.BackendProto.GraphsPreferences.Weekday; /* enum */ +type WeekdayType = pb.BackendProto.GraphPreferences.Weekday; +const Weekday = pb.BackendProto.GraphPreferences.Weekday; /* enum */ export function gatherData( data: pb.BackendProto.GraphsOut, diff --git a/ts/graphs/graph-helpers.ts b/ts/graphs/graph-helpers.ts index 5e9fd1e8a..44934827f 100644 --- a/ts/graphs/graph-helpers.ts +++ b/ts/graphs/graph-helpers.ts @@ -20,8 +20,8 @@ export async function getGraphData( ); } -export async function getGraphPreferences(): Promise { - return pb.BackendProto.GraphsPreferences.decode( +export async function getGraphPreferences(): Promise { + return pb.BackendProto.GraphPreferences.decode( await postRequest("/_anki/graphPreferences", JSON.stringify({})) ); } @@ -30,7 +30,7 @@ export async function setGraphPreferences(prefs: PreferencePayload): Promise => { await postRequest( "/_anki/setGraphPreferences", - pb.BackendProto.GraphsPreferences.encode(prefs).finish() + pb.BackendProto.GraphPreferences.encode(prefs).finish() ); })(); } diff --git a/ts/graphs/preferences.ts b/ts/graphs/preferences.ts index 7da866527..5dad878a2 100644 --- a/ts/graphs/preferences.ts +++ b/ts/graphs/preferences.ts @@ -8,16 +8,16 @@ export interface CustomStore extends Writable { } export type PreferenceStore = { - [K in keyof Omit]: CustomStore< - pb.BackendProto.GraphsPreferences[K] + [K in keyof Omit]: CustomStore< + pb.BackendProto.GraphPreferences[K] >; }; export type PreferencePayload = { [K in keyof Omit< - pb.BackendProto.GraphsPreferences, + pb.BackendProto.GraphPreferences, "toJSON" - >]: pb.BackendProto.GraphsPreferences[K]; + >]: pb.BackendProto.GraphPreferences[K]; }; function createPreference( @@ -40,7 +40,7 @@ function createPreference( } function preparePreferences( - graphsPreferences: pb.BackendProto.GraphsPreferences + GraphPreferences: pb.BackendProto.GraphPreferences ): PreferenceStore { const preferences: Partial = {}; @@ -59,7 +59,7 @@ function preparePreferences( } for (const [key, value] of Object.entries( - pb.BackendProto.GraphsPreferences.toObject(graphsPreferences, { + pb.BackendProto.GraphPreferences.toObject(GraphPreferences, { defaults: true, }) )) {