Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

760 B
Raw Blame
import { queryClient } from '../client';
import { emailKeys } from './keys';

// Saving a draft must not invalidate an active thread resource: doing so can
// detach its Suspense subtree and reset the editor and scroll position.
const savedThreads = new Set<string>();

export function markThreadDraftSaved(threadId: string) {
  savedThreads.add(threadId);
  // A save can settle after thread cleanup, or without mounting the thread.
  queryClient.removeQueries({
    queryKey: emailKeys.threadMessages(threadId).queryKey,
    type: 'inactive',
  });
}

export function clearSavedDraftThreadCache(threadId: string) {
  if (!savedThreads.delete(threadId)) return;
  queryClient.removeQueries({
    queryKey: emailKeys.threadMessages(threadId).queryKey,
  });
}