minor wording tweak: GraphsPreferences -> GraphPreferences
This commit is contained in:
parent
6f798930a2
commit
37ca8afaf6
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -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<pb::GraphsPreferences> {
|
||||
self.with_col(|col| col.get_graphs_preferences())
|
||||
fn get_graph_preferences(&self, _input: pb::Empty) -> BackendResult<pb::GraphPreferences> {
|
||||
self.with_col(|col| col.get_graph_preferences())
|
||||
}
|
||||
|
||||
fn set_graphs_preferences(&self, input: pb::GraphsPreferences) -> BackendResult<Empty> {
|
||||
self.with_col(|col| col.set_graphs_preferences(input))
|
||||
fn set_graph_preferences(&self, input: pb::GraphPreferences) -> BackendResult<Empty> {
|
||||
self.with_col(|col| col.set_graph_preferences(input))
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
|
@ -47,14 +47,14 @@ impl Collection {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn get_graphs_preferences(&self) -> Result<pb::GraphsPreferences> {
|
||||
Ok(pb::GraphsPreferences {
|
||||
pub(crate) fn get_graph_preferences(&self) -> Result<pb::GraphPreferences> {
|
||||
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,
|
||||
|
@ -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,
|
||||
|
@ -20,8 +20,8 @@ export async function getGraphData(
|
||||
);
|
||||
}
|
||||
|
||||
export async function getGraphPreferences(): Promise<pb.BackendProto.GraphsPreferences> {
|
||||
return pb.BackendProto.GraphsPreferences.decode(
|
||||
export async function getGraphPreferences(): Promise<pb.BackendProto.GraphPreferences> {
|
||||
return pb.BackendProto.GraphPreferences.decode(
|
||||
await postRequest("/_anki/graphPreferences", JSON.stringify({}))
|
||||
);
|
||||
}
|
||||
@ -30,7 +30,7 @@ export async function setGraphPreferences(prefs: PreferencePayload): Promise<voi
|
||||
return (async (): Promise<void> => {
|
||||
await postRequest(
|
||||
"/_anki/setGraphPreferences",
|
||||
pb.BackendProto.GraphsPreferences.encode(prefs).finish()
|
||||
pb.BackendProto.GraphPreferences.encode(prefs).finish()
|
||||
);
|
||||
})();
|
||||
}
|
||||
|
@ -8,16 +8,16 @@ export interface CustomStore<T> extends Writable<T> {
|
||||
}
|
||||
|
||||
export type PreferenceStore = {
|
||||
[K in keyof Omit<pb.BackendProto.GraphsPreferences, "toJSON">]: CustomStore<
|
||||
pb.BackendProto.GraphsPreferences[K]
|
||||
[K in keyof Omit<pb.BackendProto.GraphPreferences, "toJSON">]: 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<T>(
|
||||
@ -40,7 +40,7 @@ function createPreference<T>(
|
||||
}
|
||||
|
||||
function preparePreferences(
|
||||
graphsPreferences: pb.BackendProto.GraphsPreferences
|
||||
GraphPreferences: pb.BackendProto.GraphPreferences
|
||||
): PreferenceStore {
|
||||
const preferences: Partial<PreferenceStore> = {};
|
||||
|
||||
@ -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,
|
||||
})
|
||||
)) {
|
||||
|
Loading…
Reference in New Issue
Block a user