Path: blob/main/components/dashboard/src/data/workspaces/default-workspace-image-query.ts
2501 views
/**1* Copyright (c) 2023 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { useQuery } from "@tanstack/react-query";7import { GetWorkspaceDefaultImageResponse } from "@gitpod/public-api/lib/gitpod/v1/workspace_pb";8import { workspaceClient } from "../../service/public-api";910export const useWorkspaceDefaultImageQuery = (workspaceId?: string) => {11return useQuery<GetWorkspaceDefaultImageResponse | null, Error, GetWorkspaceDefaultImageResponse | undefined>({12queryKey: ["default-workspace-image-v2", { workspaceId: workspaceId || "undefined" }],13staleTime: 1000 * 60 * 10, // 10 minute14queryFn: async () => {15if (!workspaceId) {16return null; // no workspaceId, no image. Using null because "undefined" is not persisted by react-query17}18return await workspaceClient.getWorkspaceDefaultImage({ workspaceId });19},20select: (data) => data || undefined,21});22};232425