ReviewOS

also looking at this

craft-native/craft

fix(bridge): stop discarding the fields the page actually sends

#82
Merged glennmichael123 wants to merge fix/bridge-field-names into main
7 files +375 -34
packages/zig/src/bridge_updater.zigmodified+10-2
Changes to packages/zig/src/bridge_updater.zig
@@ -213,7 +213,12 @@ pub const UpdaterBridge = struct {
213213
214214 const macos = ;
215215
216 // `craft.updater.setAutomaticChecks(on)` sends `{"value":…}`; this
217 // declared only `enabled`, so `ignore_unknown_fields` dropped the
218 // boolean and every call read the `false` default — automatic checks
219 // could be turned off but never on. `enabled` stays accepted.
216220 const EnabledParams = struct {
221 value: ?bool = null,
217222 enabled: bool = false,
218223 };
219224
@@ -222,7 +227,7 @@ pub const UpdaterBridge = struct {
222227 .allocate = .alloc_always,
223228 }) catch return BridgeError.InvalidJSON;
224229 defer parsed.deinit();
225 const enabled = parsed.value.enabled;
230 const enabled = parsed.value.value orelse parsed.value.enabled;
226231
227232 self.automatic_checks = enabled;
228233
@@ -242,7 +247,10 @@ pub const UpdaterBridge = struct {
242247
243248 const macos = ;
244249
250 // Same mismatch: the page sends `{"seconds":…}` and this declared only
251 // `interval`, so every interval silently stayed at the 24-hour default.
245252 const IntervalParams = struct {
253 seconds: ?u32 = null,
246254 interval: u32 = 86400,
247255 };
248256
@@ -251,7 +259,7 @@ pub const UpdaterBridge = struct {
251259 .allocate = .alloc_always,
252260 }) catch return BridgeError.InvalidJSON;
253261 defer parsed.deinit();
254 const interval = parsed.value.interval;
262 const interval = parsed.value.seconds orelse parsed.value.interval;
255263
256264 self.check_interval = interval;
257265