mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
expose stock notetypes
This commit is contained in:
parent
fcb8567185
commit
d6646a6db5
4 changed files with 19 additions and 1 deletions
|
@ -69,6 +69,7 @@ message BackendInput {
|
||||||
bytes set_all_notetypes = 57;
|
bytes set_all_notetypes = 57;
|
||||||
Empty get_all_decks = 58;
|
Empty get_all_decks = 58;
|
||||||
bytes set_all_decks = 59;
|
bytes set_all_decks = 59;
|
||||||
|
Empty all_stock_notetypes = 60;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +86,7 @@ message BackendOutput {
|
||||||
string studied_today = 32;
|
string studied_today = 32;
|
||||||
string congrats_learn_msg = 33;
|
string congrats_learn_msg = 33;
|
||||||
Empty abort_media_sync = 46;
|
Empty abort_media_sync = 46;
|
||||||
|
AllStockNotetypesOut all_stock_notetypes = 60;
|
||||||
|
|
||||||
// fallible commands
|
// fallible commands
|
||||||
TemplateRequirementsOut template_requirements = 16;
|
TemplateRequirementsOut template_requirements = 16;
|
||||||
|
@ -560,3 +562,7 @@ enum StockNoteType {
|
||||||
StockNoteTypeBasicTyping = 3;
|
StockNoteTypeBasicTyping = 3;
|
||||||
StockNoteTypeCloze = 4;
|
StockNoteTypeCloze = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message AllStockNotetypesOut {
|
||||||
|
repeated NoteType notetypes = 1;
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ SchedTimingToday = pb.SchedTimingTodayOut
|
||||||
BuiltinSortKind = pb.BuiltinSearchOrder.BuiltinSortKind
|
BuiltinSortKind = pb.BuiltinSearchOrder.BuiltinSortKind
|
||||||
BackendCard = pb.Card
|
BackendCard = pb.Card
|
||||||
TagUsnTuple = pb.TagUsnTuple
|
TagUsnTuple = pb.TagUsnTuple
|
||||||
|
NoteType = pb.NoteType
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import orjson
|
import orjson
|
||||||
|
@ -626,6 +627,13 @@ class RustBackend:
|
||||||
def set_all_decks(self, nts: Dict[str, Dict[str, Any]]):
|
def set_all_decks(self, nts: Dict[str, Dict[str, Any]]):
|
||||||
self._run_command(pb.BackendInput(set_all_decks=orjson.dumps(nts)))
|
self._run_command(pb.BackendInput(set_all_decks=orjson.dumps(nts)))
|
||||||
|
|
||||||
|
def all_stock_notetypes(self) -> List[NoteType]:
|
||||||
|
return list(
|
||||||
|
self._run_command(
|
||||||
|
pb.BackendInput(all_stock_notetypes=pb.Empty())
|
||||||
|
).all_stock_notetypes.notetypes
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def translate_string_in(
|
def translate_string_in(
|
||||||
key: TR, **kwargs: Union[str, int, float]
|
key: TR, **kwargs: Union[str, int, float]
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::{
|
||||||
media::sync::MediaSyncProgress,
|
media::sync::MediaSyncProgress,
|
||||||
media::MediaManager,
|
media::MediaManager,
|
||||||
notes::NoteID,
|
notes::NoteID,
|
||||||
notetype::{NoteTypeID, NoteTypeSchema11},
|
notetype::{all_stock_notetypes, NoteTypeID, NoteTypeSchema11},
|
||||||
sched::cutoff::{local_minutes_west_for_stamp, sched_timing_today},
|
sched::cutoff::{local_minutes_west_for_stamp, sched_timing_today},
|
||||||
sched::timespan::{answer_button_time, learning_congrats, studied_today, time_span},
|
sched::timespan::{answer_button_time, learning_congrats, studied_today, time_span},
|
||||||
search::{search_cards, search_notes, SortMode},
|
search::{search_cards, search_notes, SortMode},
|
||||||
|
@ -318,6 +318,9 @@ impl Backend {
|
||||||
self.set_all_decks(&bytes)?;
|
self.set_all_decks(&bytes)?;
|
||||||
OValue::SetAllDecks(pb::Empty {})
|
OValue::SetAllDecks(pb::Empty {})
|
||||||
}
|
}
|
||||||
|
Value::AllStockNotetypes(_) => OValue::AllStockNotetypes(pb::AllStockNotetypesOut {
|
||||||
|
notetypes: all_stock_notetypes(&self.i18n),
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub use crate::backend_proto::{
|
||||||
NoteField, NoteFieldConfig, NoteType, NoteTypeConfig, NoteTypeKind,
|
NoteField, NoteFieldConfig, NoteType, NoteTypeConfig, NoteTypeKind,
|
||||||
};
|
};
|
||||||
pub use schema11::{CardTemplateSchema11, NoteFieldSchema11, NoteTypeSchema11};
|
pub use schema11::{CardTemplateSchema11, NoteFieldSchema11, NoteTypeSchema11};
|
||||||
|
pub use stock::all_stock_notetypes;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
define_newtype,
|
define_newtype,
|
||||||
|
|
Loading…
Reference in a new issue