-
Notifications
You must be signed in to change notification settings - Fork 1.3k
undo limit to fetch the first 100 user repos for New Workspace β EXP-554 #18644
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,10 @@ | |
* See License.AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useContext } from "react"; | ||
import { useContext, useEffect } from "react"; | ||
import { UserContext } from "../user-context"; | ||
import { getGitpodService } from "../service/service"; | ||
import { trackLocation } from "../Analytics"; | ||
import { refreshSearchData } from "../components/RepositoryFinder"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { noPersistence } from "../data/setup"; | ||
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; | ||
|
@@ -20,7 +19,7 @@ export const useUserLoader = () => { | |
|
||
// For now, we're using the user context to store the user, but letting react-query handle the loading | ||
// In the future, we should remove the user context and use react-query to access the user | ||
const { isLoading } = useQuery({ | ||
const userQuery = useQuery({ | ||
queryKey: noPersistence(["current-user"]), | ||
queryFn: async () => { | ||
const user = await getGitpodService().server.getLoggedInUser(); | ||
|
@@ -41,14 +40,18 @@ export const useUserLoader = () => { | |
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), | ||
cacheTime: 1000 * 60 * 60 * 1, // 1 hour | ||
staleTime: 1000 * 60 * 60 * 1, // 1 hour | ||
onSuccess: (loadedUser) => { | ||
setUser(loadedUser); | ||
refreshSearchData(); | ||
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. @svenefftinge, maybe you recall why this was introduced? 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. Does RepositoryFinder depend on any user properties that it should be retriggered? if not it should not be here? It looks rather strange way of doing, we would provide user state as a dependency to RepositoryFinder if we want to do it properly? cc @selfcontained 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. Good question! π€·π»ββοΈ |
||
}, | ||
|
||
onSettled: (loadedUser) => { | ||
trackLocation(!!loadedUser); | ||
}, | ||
}); | ||
|
||
return { user, loading: isLoading }; | ||
// onSuccess is deprecated: https://tkdodo.eu/blog/breaking-react-querys-api-on-purpose | ||
useEffect(() => { | ||
if (userQuery.data) { | ||
setUser(userQuery.data); | ||
} | ||
}, [userQuery.data, setUser]); | ||
|
||
return { user, loading: userQuery.isLoading }; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While testing this, I was wondering if we could add a trailing element which indicates that this list is truncated.