fix graphs failing to load until preferences set

The protobuf object will be missing keys that have the default value,
so we need to fill the defaults in.
This commit is contained in:
Damien Elmes 2021-01-23 20:40:43 +10:00
parent bf130d1da0
commit 6f798930a2

View file

@ -1,4 +1,4 @@
import type pb from "anki/backend_proto";
import pb from "anki/backend_proto";
import { getGraphPreferences, setGraphPreferences } from "./graph-helpers";
import { Writable, writable, get } from "svelte/store";
@ -58,7 +58,11 @@ function preparePreferences(
setGraphPreferences(constructPreferences());
}
for (const [key, value] of Object.entries(graphsPreferences)) {
for (const [key, value] of Object.entries(
pb.BackendProto.GraphsPreferences.toObject(graphsPreferences, {
defaults: true,
})
)) {
preferences[key] = createPreference(value, savePreferences);
}