-
Notifications
You must be signed in to change notification settings - Fork 897
chore: reduce dashboard requests from seeded data #13034
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fd977e2
chore: reduce requests the dashboard makes from seeded data
kylecarbs 792aa63
Fix first user fetch
kylecarbs 94adf60
Add util
kylecarbs 43cb86b
Add cached query for entitlements and experiments
kylecarbs aa2cb8f
Fix authmethods unnecessary request
kylecarbs 64b770e
Fix unnecessary region request
kylecarbs ebf13d5
Fix fmt
kylecarbs 60fed57
Debug
kylecarbs 9f369ac
Fix test
kylecarbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
chore: reduce requests the dashboard makes from seeded data
We already inject all of this content in `index.html`. There was also a bug with displaying a loading indicator when the workspace proxies endpoint 404s.
- Loading branch information
commit fd977e22bc41cde5cb671ad1d5964a01886fc5c6
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,8 @@ export const updateRoles = (queryClient: QueryClient) => { | |
}; | ||
}; | ||
|
||
const initialUserData = getMetadataAsJSON<User>("user"); | ||
|
||
export const authMethods = () => { | ||
return { | ||
// Even the endpoint being /users/authmethods we don't want to revalidate it | ||
|
@@ -121,18 +123,26 @@ export const authMethods = () => { | |
}; | ||
}; | ||
|
||
const initialUserData = getMetadataAsJSON<User>("user"); | ||
|
||
const meKey = ["me"]; | ||
|
||
export const me = (): UseQueryOptions<User> & { | ||
queryKey: QueryKey; | ||
} => { | ||
return { | ||
export const me = () => { | ||
const opts: UseQueryOptions<User> & { | ||
queryKey: QueryKey; | ||
} = { | ||
queryKey: meKey, | ||
initialData: initialUserData, | ||
queryFn: API.getAuthenticatedUser, | ||
}; | ||
// If we have initial user data, we don't want to fetch | ||
// the user again. We already have it! | ||
if (initialUserData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
opts.cacheTime = Infinity; | ||
opts.staleTime = Infinity; | ||
opts.refetchOnMount = false; | ||
opts.refetchOnReconnect = false; | ||
opts.refetchOnWindowFocus = false; | ||
} | ||
return opts; | ||
}; | ||
|
||
export function apiKey(): UseQueryOptions<GenerateAPIKeyResponse> { | ||
|
@@ -142,8 +152,14 @@ export function apiKey(): UseQueryOptions<GenerateAPIKeyResponse> { | |
}; | ||
} | ||
|
||
export const hasFirstUser = () => { | ||
export const hasFirstUser = (): UseQueryOptions<boolean> => { | ||
return { | ||
// If there is initial user data, we don't want to make | ||
// this request. It's a waste! | ||
cacheTime: Infinity, | ||
staleTime: Infinity, | ||
initialData: Boolean(initialUserData), | ||
|
||
queryKey: ["hasFirstUser"], | ||
queryFn: API.hasFirstUser, | ||
}; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.