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

Fix react-query cache persistence #18762

Merged
merged 5 commits into from
Sep 21, 2023
Merged

Conversation

selfcontained
Copy link
Contributor

@selfcontained selfcontained commented Sep 20, 2023

Description

Found a bug where we end up always clearing the query cache on page load. This adjusts some of the logic with where/how we reset that cache so we benefit from loading up the cache from IDB.

Instead of the logic that was there, which would clear the cache anytime the user id changes in UserContext, I've adjust it to only do that when we have a user in context already. This avoids clearing it on initial page load. I've also added explicit clearing of the cache on logout and login.

I've also updated the icons in the repository selector to remove the color distinction between projects non-project suggestions. We may revisit the iconography and colors later.

image
Summary generated by Copilot

🤖 Generated by Copilot at 1e0af49

This pull request enhances the data fetching and caching logic for the login and user menu components, using React Query hooks and clearing the cache when appropriate. It also improves the user context management by syncing it with the query cache.

Related Issue(s)

Fixes EXP-655

How to test

  • Visit the /new page for creating a new workspace.
  • The first time you visit it, the repository selector should have a loading state until it finishes loading the suggestions.
  • Do a hard refresh and it should show suggestions right away w/o a loading state.
  • Verify projects are listed in the selector w/o any color indicator.

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@roboquat roboquat added size/L and removed size/M labels Sep 20, 2023
@selfcontained
Copy link
Contributor Author

/gh run

@selfcontained selfcontained marked this pull request as ready for review September 20, 2023 19:19
@selfcontained selfcontained requested a review from a team as a code owner September 20, 2023 19:19
Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

Preview environment is not working but UX LGTM in the screenshot. 🏁
Thanks @selfcontained. 🌮

I kinda miss the differentiation of the project, but hopefully we can get back to it soon.

@@ -29,7 +29,9 @@ const UserContextProvider: React.FC = ({ children }) => {
const doSetUser = useCallback(
(updatedUser: User) => {
updateErrorUserDetails(updatedUser);
if (user?.id !== updatedUser.id) {
// If user has changed clear cache
// Ignore the case where user hasn't been set yet - initial load
Copy link
Member

Choose a reason for hiding this comment

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

🥇

@selfcontained
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit b02c94d into main Sep 21, 2023
25 checks passed
@roboquat roboquat deleted the brad/query-cache-get-suggested-repos branch September 21, 2023 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants