MCPcopy Index your code
hub / github.com/coder/coder / toggleFavorite

Function toggleFavorite

site/src/api/queries/workspaces.ts:448–472  ·  view source on GitHub ↗
(
	workspace: Workspace,
	queryClient: QueryClient,
)

Source from the content-addressed store, hash-verified

446};
447
448export const toggleFavorite = (
449 workspace: Workspace,
450 queryClient: QueryClient,
451) => {
452 return {
453 mutationFn: () => {
454 if (workspace.favorite) {
455 return API.deleteFavoriteWorkspace(workspace.id);
456 }
457 return API.putFavoriteWorkspace(workspace.id);
458 },
459 onSuccess: async () => {
460 queryClient.setQueryData(
461 workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
462 { ...workspace, favorite: !workspace.favorite },
463 );
464 await queryClient.invalidateQueries({
465 queryKey: workspaceByOwnerAndNameKey(
466 workspace.owner_name,
467 workspace.name,
468 ),
469 });
470 },
471 };
472};
473
474export const buildLogsKey = (workspaceId: string) => [
475 "workspaces",

Callers 1

WorkspaceReadyPageFunction · 0.90

Calls 3

putFavoriteWorkspaceMethod · 0.80

Tested by

no test coverage detected