diff --git a/proto/anki/generic.proto b/proto/anki/generic.proto index 5156e48d6..83f765b46 100644 --- a/proto/anki/generic.proto +++ b/proto/anki/generic.proto @@ -7,14 +7,6 @@ package anki.generic; message Empty {} -message OptionalInt32 { - sint32 val = 1; -} - -message OptionalUInt32 { - uint32 val = 1; -} - message Int32 { sint32 val = 1; } diff --git a/proto/anki/notetypes.proto b/proto/anki/notetypes.proto index 9bf0c7bb0..cf86686da 100644 --- a/proto/anki/notetypes.proto +++ b/proto/anki/notetypes.proto @@ -71,7 +71,7 @@ message Notetype { bytes other = 255; } - generic.OptionalUInt32 ord = 1; + generic.UInt32 ord = 1; string name = 2; Config config = 5; } @@ -88,7 +88,7 @@ message Notetype { bytes other = 255; } - generic.OptionalUInt32 ord = 1; + generic.UInt32 ord = 1; string name = 2; int64 mtime_secs = 3; sint32 usn = 4; diff --git a/rslib/src/notetype/fields.rs b/rslib/src/notetype/fields.rs index e0b2ddc5c..edfd69804 100644 --- a/rslib/src/notetype/fields.rs +++ b/rslib/src/notetype/fields.rs @@ -3,7 +3,7 @@ use super::{NoteFieldConfig, NoteFieldProto}; use crate::{ - backend_proto::OptionalUInt32, + backend_proto::UInt32, error::{AnkiError, Result}, }; @@ -17,7 +17,7 @@ pub struct NoteField { impl From for NoteFieldProto { fn from(f: NoteField) -> Self { NoteFieldProto { - ord: f.ord.map(|n| OptionalUInt32 { val: n }), + ord: f.ord.map(|n| UInt32 { val: n }), name: f.name, config: Some(f.config), } diff --git a/rslib/src/notetype/templates.rs b/rslib/src/notetype/templates.rs index 5c82b9a21..b9ac062fc 100644 --- a/rslib/src/notetype/templates.rs +++ b/rslib/src/notetype/templates.rs @@ -3,7 +3,7 @@ use super::{CardTemplateConfig, CardTemplateProto}; use crate::{ - backend_proto::OptionalUInt32, + backend_proto::UInt32, decks::DeckId, error::{AnkiError, Result}, template::ParsedTemplate, @@ -57,7 +57,7 @@ impl CardTemplate { impl From for CardTemplateProto { fn from(t: CardTemplate) -> Self { CardTemplateProto { - ord: t.ord.map(|n| OptionalUInt32 { val: n }), + ord: t.ord.map(|n| UInt32 { val: n }), mtime_secs: t.mtime_secs.0, usn: t.usn.0, name: t.name, diff --git a/ts/card-info/Revlog.svelte b/ts/card-info/Revlog.svelte index f8ec555c4..6aceabdd7 100644 --- a/ts/card-info/Revlog.svelte +++ b/ts/card-info/Revlog.svelte @@ -9,9 +9,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let stats: Stats.CardStatsResponse; - type IStatsRevlogEntry = Stats.CardStatsResponse.IStatsRevlogEntry; + type StatsRevlogEntry = Stats.CardStatsResponse.StatsRevlogEntry; - function reviewKindClass(entry: IStatsRevlogEntry): string { + function reviewKindClass(entry: StatsRevlogEntry): string { switch (entry.reviewKind) { case Stats.RevlogEntry.ReviewKind.LEARNING: return "revlog-learn"; @@ -23,7 +23,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html return ""; } - function reviewKindLabel(entry: IStatsRevlogEntry): string { + function reviewKindLabel(entry: StatsRevlogEntry): string { switch (entry.reviewKind) { case Stats.RevlogEntry.ReviewKind.LEARNING: return tr2.cardStatsReviewLogTypeLearn(); @@ -38,7 +38,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } } - function ratingClass(entry: IStatsRevlogEntry): string { + function ratingClass(entry: StatsRevlogEntry): string { if (entry.buttonChosen === 1) { return "revlog-ease1"; } @@ -57,23 +57,25 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html takenSecs: string; } - function revlogRowFromEntry(entry: IStatsRevlogEntry): RevlogRow { - const timestamp = new Timestamp(entry.time!); + function revlogRowFromEntry(entry: StatsRevlogEntry): RevlogRow { + const timestamp = new Timestamp(entry.time); return { date: timestamp.dateString(), time: timestamp.timeString(), reviewKind: reviewKindLabel(entry), reviewKindClass: reviewKindClass(entry), - rating: entry.buttonChosen!, + rating: entry.buttonChosen, ratingClass: ratingClass(entry), - interval: timeSpan(entry.interval!), + interval: timeSpan(entry.interval), ease: entry.ease ? `${entry.ease / 10}%` : "", - takenSecs: timeSpan(entry.takenSecs!, true), + takenSecs: timeSpan(entry.takenSecs, true), }; } let revlogRows: RevlogRow[]; - $: revlogRows = stats.revlog.map((entry) => revlogRowFromEntry(entry)); + $: revlogRows = stats.revlog.map((entry) => + revlogRowFromEntry(entry as StatsRevlogEntry), + ); {#if stats.revlog.length} diff --git a/ts/lib/proto.ts b/ts/lib/proto.ts index 9e5ce15fd..941359ddf 100644 --- a/ts/lib/proto.ts +++ b/ts/lib/proto.ts @@ -14,14 +14,7 @@ import Tags = anki.tags; export { Stats, Cards, DeckConfig, Notetypes, Scheduler, Tags }; export function unwrapOptionalNumber( - msg: - | Generic.IInt64 - | Generic.IUInt32 - | Generic.IInt32 - | Generic.OptionalInt32 - | Generic.OptionalUInt32 - | null - | undefined, + msg: Generic.IInt64 | Generic.IUInt32 | Generic.IInt32 | null | undefined, ): number | undefined { if (msg && msg !== null) { if (msg.val !== null) {