diff --git a/frontend/src/app/context-switcher.tsx b/frontend/src/app/context-switcher.tsx
index 7cf9215c74..6a2c53b60a 100644
--- a/frontend/src/app/context-switcher.tsx
+++ b/frontend/src/app/context-switcher.tsx
@@ -1,6 +1,11 @@
import { useClerk } from "@clerk/clerk-react";
+import { type Project } from "@rivet-gg/cloud";
import { faChevronDown, faPlusCircle, Icon } from "@rivet-gg/icons";
-import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
+import {
+ useInfiniteQuery,
+ usePrefetchInfiniteQuery,
+ useQuery,
+} from "@tanstack/react-query";
import { useMatchRoute, useNavigate, useParams } from "@tanstack/react-router";
import { useState } from "react";
import {
@@ -26,6 +31,16 @@ export function ContextSwitcher() {
const match = useContextSwitchMatch();
+ usePrefetchInfiniteQuery({
+ enabled: typeof match === "object" && "organization" in match,
+ ...useCloudDataProvider().projectsQueryOptions({
+ organization:
+ typeof match === "object" && "organization" in match
+ ? match.organization
+ : "",
+ }),
+ });
+
if (!match) {
return null;
}
@@ -214,13 +229,13 @@ function ProjectList({
}),
);
const navigate = useNavigate();
- const clerk = useClerk();
const project = useParams({
strict: false,
select(params) {
return params.project;
},
});
+ const clerk = useClerk();
return (
@@ -255,41 +270,28 @@ function ProjectList({
) : null}
- {data?.map((project) => (
-
- {
- clerk.setActive({
- organization,
- });
- navigate({
- to: "/orgs/$organization/projects/$project",
- params: {
- organization: organization,
- project: project.name,
- },
- });
- onClose?.();
- }}
- onMouseEnter={() => {
- onHover?.(project.name);
- }}
- onFocus={() => {
- onHover?.(project.name);
- }}
- >
-
- {project.displayName}
-
-
-
- ))}
+ {data?.map((project, index) => {
+ const Component = index < 5 ? PrefetchedProjectListItem : ProjectListItem;
+ return
onHover?.(project.name)}
+ onSelect={() => {
+ onClose?.();
+ clerk.setActive({
+ organization,
+ });
+ return navigate({
+ to: "/orgs/$organization/projects/$project",
+ params: {
+ organization: organization,
+ project: project.name,
+ },
+ search: {},
+ });
+ }}
+ />
+ })}
{isLoading || isFetchingNextPage ? (
<>
@@ -327,6 +329,46 @@ function ProjectList({
);
}
+function PrefetchedProjectListItem({
+ id,
+ name,
+ displayName,
+}: Project) {
+ usePrefetchInfiniteQuery({
+ ...useCloudDataProvider().currentOrgProjectNamespacesQueryOptions({
+ project: name,
+ }),
+ });
+
+ return ;
+}
+
+function ProjectListItem({
+ id,
+ name,
+ displayName,
+ onHover,
+ onSelect,
+}: Project & {
+ onHover?: () => void;
+ onSelect?: () => void;
+}) {
+ return (
+
+
+ {displayName}
+
+
+ );
+}
+
function ListItemSkeleton() {
return (
diff --git a/frontend/src/routes/_context/_cloud/orgs.$organization/projects.$project/ns.$namespace/tokens.tsx b/frontend/src/routes/_context/_cloud/orgs.$organization/projects.$project/ns.$namespace/tokens.tsx
index 97c2b9b219..ee304ebe99 100644
--- a/frontend/src/routes/_context/_cloud/orgs.$organization/projects.$project/ns.$namespace/tokens.tsx
+++ b/frontend/src/routes/_context/_cloud/orgs.$organization/projects.$project/ns.$namespace/tokens.tsx
@@ -140,8 +140,6 @@ function SecretToken() {
string | undefined
>(undefined);
- console.log(regions, selectedDatacenter);
-
// Set default datacenter when regions are loaded
useEffect(() => {
if (regions.length > 0 && !selectedDatacenter) {