Migrate quick start tour to temporary settings storage
Created by: erzhtor
Closes https://github.com/sourcegraph/sourcegraph/issues/35858.
Description
This PR:
- Migrates quick start tour to temporary settings storage to persist state across devices/browsers
- Updates
useTemporarySettings
implementation to handle allsetValueAndSave
calls with latest previous value// Previously const [value, setValue] = useTemporarySettings('my.settings.value') setValue(prevValue => ...) setValue(prevValue => ...) // here prevValue sometimes is not up to date // Now const [value, setValue] = useTemporarySettings('my.settings.value') setValue(prevValue => ...) setValue(prevValue => ...) // updated latest prevValue since under the hood it uses React.useState
- Updates
useTemporarySettings
to return load status:const [value, setValue, status] = useTemporarySettings('my.settings.value') status // 'initial' | 'loaded' | 'error'
- Adds
useObservableWithStatus
helper utility which has observable value, loading status and error:/* [value, 'initial' | 'next' | 'completed' | 'error', Error | undefined] */ const [value, status, error] = useObservableWithStatus($observable)
Test plan
- Unit tests updated/added
- Manually test
- Run
sg start dotcom
from the main branch - Click on quick start tour to make some completion progress
- Switch to the PR branch and rerun app
- Make sure progress is still there
- Also, you check that authenticated quick start tour progress is persistent across browsers when signed in with the same account
- Run
App preview:
Check out the client app preview documentation to learn more.