also looking at this
fix(bridge): stop discarding the fields the page actually sends
#82
7 files
+375
-34
| @@ -213,7 +213,12 @@ pub const UpdaterBridge = struct { | ||
| 213 | 213 | |
| 214 | 214 | const macos = ; |
| 215 | 215 | |
| 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. | |
| 216 | 220 | const EnabledParams = struct { |
| 221 | value: ?bool = null, | |
| 217 | 222 | enabled: bool = false, |
| 218 | 223 | }; |
| 219 | 224 | |
| @@ -222,7 +227,7 @@ pub const UpdaterBridge = struct { | ||
| 222 | 227 | .allocate = .alloc_always, |
| 223 | 228 | }) catch return BridgeError.InvalidJSON; |
| 224 | 229 | defer parsed.deinit(); |
| 225 | const enabled = parsed.value.enabled; | |
| 230 | const enabled = parsed.value.value orelse parsed.value.enabled; | |
| 226 | 231 | |
| 227 | 232 | self.automatic_checks = enabled; |
| 228 | 233 | |
| @@ -242,7 +247,10 @@ pub const UpdaterBridge = struct { | ||
| 242 | 247 | |
| 243 | 248 | const macos = ; |
| 244 | 249 | |
| 250 | // Same mismatch: the page sends `{"seconds":…}` and this declared only | |
| 251 | // `interval`, so every interval silently stayed at the 24-hour default. | |
| 245 | 252 | const IntervalParams = struct { |
| 253 | seconds: ?u32 = null, | |
| 246 | 254 | interval: u32 = 86400, |
| 247 | 255 | }; |
| 248 | 256 | |
| @@ -251,7 +259,7 @@ pub const UpdaterBridge = struct { | ||
| 251 | 259 | .allocate = .alloc_always, |
| 252 | 260 | }) catch return BridgeError.InvalidJSON; |
| 253 | 261 | defer parsed.deinit(); |
| 254 | const interval = parsed.value.interval; | |
| 262 | const interval = parsed.value.seconds orelse parsed.value.interval; | |
| 255 | 263 | |
| 256 | 264 | self.check_interval = interval; |
| 257 | 265 | |