import type { QueryClient } from "@tanstack/react-query";

/**
 * Every cached read that shows an event. With a one-minute `staleTime`, an
 * edit used to land on the detail page still showing the pre-edit copy, and a
 * new or deleted event took up to a minute to appear in (or leave) the lists.
 */
const EVENT_READ_KEYS = [["event-details"], ["events-list"], ["profile-events"], ["events-homepage"]] as const;

export function invalidateEventReads(queryClient: QueryClient): Promise<void> {
  return Promise.all(EVENT_READ_KEYS.map((queryKey) => queryClient.invalidateQueries({ queryKey: [...queryKey] }))).then(() => undefined);
}
