Files
buzz/desktop/src/features/projects/useRemoveProjectRelatedChannel.ts
John Tennant eb18afaacd feat(projects): authorize home channel admins
Signed-off-by: John Tennant <jtennant@squareup.com>
2026-08-31 15:56:32 -04:00

29 lines
1.0 KiB
TypeScript

import { useMutation, useQueryClient } from "@tanstack/react-query";
import { projectsQueryKey } from "@/features/projects/hooks";
import type { Project } from "@/features/projects/projectModels";
import { removeProjectRelatedChannel } from "@/features/projects/projectRelatedChannelRevision";
import { markProjectDataAuthoritative } from "@/features/projects/projectSnapshot";
export function useRemoveProjectRelatedChannelMutation() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({
channelId,
project,
}: {
channelId: string;
project: Project;
}) => removeProjectRelatedChannel(project, channelId),
onSuccess: (project) => {
markProjectDataAuthoritative(project, "local-write");
queryClient.setQueryData<Project[]>(projectsQueryKey, (current = []) =>
current.map((candidate) =>
candidate.id === project.id ? project : candidate,
),
);
void queryClient.invalidateQueries({ queryKey: projectsQueryKey });
},
});
}