Commit 048b044
fix(import): Don't fire setLayerBinding for positions whose value already matches
PR zmkfirmware#171's import unconditionally called setLayerBinding for every
binding parsed out of the file. Even when the file value was
identical to the device's current value (e.g. the user re-imported
their own export with no edits), the firmware still flipped its
"unsaved changes" flag because *some* setLayerBinding had been
called. Save then appeared armed for a no-op flash write, which is
both confusing and bad for flash longevity.
Diff before calling: fetch keymap.layers once, then per position
compare {behaviorId, param1, param2} against the parsed binding.
Skip the RPC when they match and count it as `unchanged`.
Reword the toast accordingly:
- Everything matched: "<file> already matches the device. No
changes needed." (info)
- Some real updates: "Updated N binding(s) from <file> (M
already matched)." with the persist
reminder.
- Partial / rejected: "Updated N (M already matched), skipped X,
rejected Y. …"
The `applied` counter is renamed `updated` to match the new
semantics. preserved / skipped / failed handling is unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 34aa60d commit 048b044
1 file changed
Lines changed: 31 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
| 420 | + | |
| 421 | + | |
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
| |||
448 | 449 | | |
449 | 450 | | |
450 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
451 | 466 | | |
452 | 467 | | |
453 | 468 | | |
| |||
459 | 474 | | |
460 | 475 | | |
461 | 476 | | |
462 | | - | |
| 477 | + | |
463 | 478 | | |
464 | 479 | | |
465 | 480 | | |
| |||
495 | 510 | | |
496 | 511 | | |
497 | 512 | | |
498 | | - | |
| 513 | + | |
499 | 514 | | |
500 | 515 | | |
501 | 516 | | |
| |||
520 | 535 | | |
521 | 536 | | |
522 | 537 | | |
523 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
524 | 543 | | |
525 | 544 | | |
526 | 545 | | |
527 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
528 | 553 | | |
529 | 554 | | |
530 | 555 | | |
531 | | - | |
| 556 | + | |
532 | 557 | | |
533 | 558 | | |
534 | 559 | | |
535 | 560 | | |
536 | 561 | | |
537 | | - | |
| 562 | + | |
538 | 563 | | |
539 | 564 | | |
540 | 565 | | |
| |||
0 commit comments