( workspace: Workspace, queryClient: QueryClient, )
| 446 | }; |
| 447 | |
| 448 | export 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 | |
| 474 | export const buildLogsKey = (workspaceId: string) => [ |
| 475 | "workspaces", |
no test coverage detected