Repository navigation
Take only the fields the page edits on the settings route - #1945
Merged
Merged
Conversation
POST /api/prefs now writes the fields the page and the desktop app edit: the notifications, tour and auto-update switches, and the LAN dialog's name, sharing, address and pairing switches. Every other field (the deck's LAN key and pairings, its port, names given to other decks, the reports switch and the reporter's state, the accounts it signed in) keeps what is on disk whatever a body names. A preference becomes writable from a page only once it is added to that list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
POST /api/prefs) only takes the fields the page edits: the notifications, tour and auto-update switches, and the LAN dialog's name, enabled, shared, addresses, current-account, pairing-mode, ask, accept and Tailscale switches. These are listed once, inPAGE_FIELDSbesidepublicPrefsindeck-prefs.mjs, and the route cuts each body down to them withpagePatch.src/weband the desktop app's notifications toggle works as before. No client changed.Verification
npm run typecheck: clean.src/web/__tests__/prefs-route-fields.test.tsposts through the real route into a realprefs.jsonand reads it back as a restart would:lan.secretandlan.trustedleaves both as they were on disk. This failed before the fix: the page's value landed.lan.unpaired,onward,port,aliases,reports,report,accounts) leaves each one as it was. This failed before the fix (lan.unpairedwas replaced).PAGE_FIELDSis exactly the listed fields. Every field in the file is either page-writable or deck-owned, by name. Every page field is exercised through the route. So adding a new page-writable field takes a deliberate change.reauth-prompt-1893.test.ts: the guard that pinned the old destructuring line now checks thatpagePatchdropsaccountsand that the route writespagePatch(body)./api/prefs(50 files, 1021 tests) passed again after rebasing on development.