lorawan-stack
lorawan-stack copied to clipboard
Fix console_preferences update
Summary
Unable to update console preferences because the exact field mask was being ignored
Changes
- Set all specific field masks for all fields of an object
Testing
Steps
There are no console preferences currently being set anywhere so I have been using this function from the frontend
const setTutorialSeen = useCallback(async () => {
const patch = {
console_preferences: {
console_theme: 'CONSOLE_THEME_LIGHT',
dashboard_layouts: {
end_device: 'DASHBOARD_LAYOUT_LIST',
gateway: 'DASHBOARD_LAYOUT_LIST',
},
sort_by: {
api_key: '-created_at',
},
tutorials: {
seen: ['TUTORIAL_LIVE_DATA_SPLIT_VIEW'],
},
},
}
await dispatch(attachPromise(updateUser({ id: user.ids.user_id, patch })))
}, [dispatch, user.ids.user_id])
Results
Regressions
...
Notes for Reviewers
This was the minimum to get this to work, I not sure if this now means we override previously set preferences if not set in request. Let me if you would like me to continue to test.
Checklist
- [ ] Scope: The referenced issue is addressed, there are no unrelated changes.
- [ ] Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in
README.mdfor the chosen target branch. - [ ] Documentation: Relevant documentation is added or updated.
- [ ] Testing: The steps/process to test this feature are clearly explained including testing for regressions.
- [ ] Infrastructure: If infrastructural changes (e.g., new RPC, configuration) are needed, a separate issue is created in the infrastructural repositories.
- [ ] Changelog: Significant features, behavior changes, deprecations and fixes are added to
CHANGELOG.md. - [ ] Commits: Commit messages follow guidelines in
CONTRIBUTING.md, there are no fixup commits left.
To provide more context, when we are updating the ConsolePreferences of a user we are fetching all of the existent ConsolePreferences JSON from the database, then we are updating the specific fields according to the submask, to finally rewrite the entire ConsolePreference JSON on the DB again.
Meaning that the only use we have for specific fieldmasks is to decrease the total size of the message sent by the Console to the IS (send only the subfield instead of the entirety of ConsolePreferences.SortBy.
@nicholaspcr Good point, I will try sending the entire json and make sure that works.
@mjamescompton: what's the status of this issue?
Some of this was handled in https://github.com/TheThingsNetwork/lorawan-stack/pull/7425
This is just that I noticed we will have the same issue with the dashboard_layouts field masks.
I will rebase this and clean this up.
This is open for so long that this is most likely out of date. Is this still relevant? @mjamescompton: Can you please make sure that you follow up on your own Github PRs?