Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): store and fetch user settings from backend #5939

Merged
merged 7 commits into from
Mar 14, 2024

Conversation

cngonzalez
Copy link
Member

@cngonzalez cngonzalez commented Mar 8, 2024

Description

We do not currently persist user settings and actions taken in the Studio in a way that follows the user. We store some user choices and actions to browser localStorage which means they do not follow users between desktop and mobile or different browsers. Browsers may also evict localStorage manually or automatically. These settings and actions are then lost and the user may need to reconfigure their experience or accept that things like search history is lost.

Not persisting this data in a universal manner gives a bad user experience since users need to make the same preference choices and settings again and again. Not having this capability also makes it harder for Sanity to develop new features that should follow the user, and we risk either continuing the localStorage limitation in new feature work, or that new initiatives all have to design their own solution for server-side settings and metadata.

What to review

Every code change in this branch was previously reviewed as part of a separate PR. However, this branch stands as the final state of this feature, and should be given "one last review."

Testing

Tests were mostly introduced in previous pull requests. This PR updates some of these tests to reflect settings no longer residing in local storage.

Notes for release

User settings (like desk list sort orders, view modes, and global search history) are now stored securely server-side by Sanity. This means that these settings do not need to be re-selected across devices or browsers, and will be persisted.

Copy link

vercel bot commented Mar 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Mar 14, 2024 5:24pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2024 5:24pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Mar 14, 2024 5:24pm

Copy link
Contributor

github-actions bot commented Mar 8, 2024

No changes to documentation

Copy link
Contributor

github-actions bot commented Mar 8, 2024

Component Testing Report Updated Mar 14, 2024 5:29 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 13s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 32s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 1s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 2s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 20s 9 0 0

@cngonzalez cngonzalez force-pushed the feat/fetch-settings-from-backend branch from e40ccc6 to edea1f6 Compare March 12, 2024 21:25
@cngonzalez cngonzalez marked this pull request as ready for review March 14, 2024 16:32
@cngonzalez cngonzalez requested a review from a team March 14, 2024 16:32
@cngonzalez cngonzalez requested a review from a team as a code owner March 14, 2024 16:32
@cngonzalez cngonzalez requested review from hermanwikner and binoy14 and removed request for a team March 14, 2024 16:32
@cngonzalez cngonzalez force-pushed the feat/fetch-settings-from-backend branch from 5f1b86d to 20cacef Compare March 14, 2024 16:41
@cngonzalez cngonzalez requested a review from jtpetty March 14, 2024 16:46
const keyValueLoader = new DataLoader<string, KeyValueStoreValue | null>(async (keys) => {
const value = await client
.request<KeyValuePair[]>({
uri: `/users/me/keyvalue/${keys.join(',')}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably fine now but if we get to where we do not have complete control over the key names, we may want to be more defensive here

Copy link
Contributor

@binoy14 binoy14 Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, the API will reject it right now but validating client side early would be nice. Not needed right now tho. Edit: not for GET

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created an issue!

@cngonzalez cngonzalez added this pull request to the merge queue Mar 14, 2024
Merged via the queue into next with commit ecb3495 Mar 14, 2024
36 checks passed
@cngonzalez cngonzalez deleted the feat/fetch-settings-from-backend branch March 14, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants