Fix: no "reviewerStorage" config default

This commit is contained in:
Luc Mcgrady 2025-11-10 09:06:45 +00:00
parent f91ba1075b
commit df58a2b36d
No known key found for this signature in database
GPG key ID: 4F3D7A0B17CC3D9C
2 changed files with 10 additions and 4 deletions

View file

@ -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)
}

View file

@ -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,
});