mirror of
https://github.com/ankitects/anki.git
synced 2026-01-07 02:53:54 -05:00
Fix: no "reviewerStorage" config default
This commit is contained in:
parent
f91ba1075b
commit
df58a2b36d
2 changed files with 10 additions and 4 deletions
|
|
@ -58,8 +58,14 @@ impl From<StringKeyProto> for StringKey {
|
|||
|
||||
impl crate::services::ConfigService for Collection {
|
||||
fn get_config_json(&mut self, input: generic::String) -> Result<generic::Json> {
|
||||
let val: Option<Value> = self.get_config_optional(input.val.as_str());
|
||||
val.or_not_found(input.val)
|
||||
let key = input.val.as_str();
|
||||
let val: Option<Value> = self.get_config_optional(key);
|
||||
let default = match key {
|
||||
"reviewerStorage" => Some(serde_json::from_str("{}").unwrap()),
|
||||
_ => None,
|
||||
};
|
||||
val.or(default)
|
||||
.or_not_found(key)
|
||||
.and_then(|v| serde_json::to_vec(&v).map_err(Into::into))
|
||||
.map(Into::into)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ export class ReviewerState {
|
|||
|
||||
async onReady() {
|
||||
this.iframe!.style.visibility = "visible";
|
||||
const { json } = await getConfigJson({ val: "reviewer_storage" });
|
||||
const { json } = await getConfigJson({ val: "reviewerStorage" });
|
||||
this.sendInnerRequest({ type: "setstorage", json_buffer: json });
|
||||
this.showQuestion(null);
|
||||
addEventListener("message", this.onMessage.bind(this));
|
||||
|
|
@ -64,7 +64,7 @@ export class ReviewerState {
|
|||
}
|
||||
case "setstorage": {
|
||||
setConfigJson({
|
||||
key: "reviewer_storage",
|
||||
key: "reviewerStorage",
|
||||
valueJson: e.data.json_buffer,
|
||||
undoable: false,
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue