lorawan-stack icon indicating copy to clipboard operation
lorawan-stack copied to clipboard

Fix console_preferences update

Open mjamescompton opened this issue 11 months ago • 4 comments

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.md for 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.

mjamescompton avatar Dec 03 '24 15:12 mjamescompton

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 avatar Jan 02 '25 12:01 nicholaspcr

@nicholaspcr Good point, I will try sending the entire json and make sure that works.

mjamescompton avatar Jan 03 '25 08:01 mjamescompton

@mjamescompton: what's the status of this issue?

KrishnaIyer avatar Jan 23 '25 08:01 KrishnaIyer

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.

mjamescompton avatar Jan 27 '25 10:01 mjamescompton

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?

KrishnaIyer avatar Jul 14 '25 09:07 KrishnaIyer