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.

1.3 KB
Raw Blame
import {
  enableGraphqlSoup,
  isFeatureEnabled,
} from '@core/constant/featureFlags';
import { queryClient } from '../client';
import { fetchGraphqlEmailThread } from '../email/graphql/thread';
import { emailKeys } from '../email/keys';
import { refetchSoupEntity } from '../soup/cache';
import { refreshActiveGraphqlSoupQueries } from '../soup/graphql/active-queries';
import { invalidateEmailReminderReads } from './email-collection';
import { reminderKeys } from './keys';

/** Scheduling and delivery both change reminder membership and inbox position. */
export async function refreshEmailFollowup(threadId: string) {
  await Promise.all([
    invalidateEmailReminderReads(),
    queryClient.invalidateQueries({
      queryKey: reminderKeys.email(threadId).queryKey,
    }),
    refetchSoupEntity(threadId, 'emailThread'),
    queryClient.invalidateQueries({
      queryKey: emailKeys.threadMessages(threadId).queryKey,
    }),
    queryClient.invalidateQueries({ queryKey: emailKeys.previews._def }),
    // Reading the thread again updates its cached record, and with it every
    // list the cache maintains; only the others are read again.
    ...(isFeatureEnabled(enableGraphqlSoup)
      ? [
          fetchGraphqlEmailThread(threadId),
          refreshActiveGraphqlSoupQueries({ unmaintainedOnly: true }),
        ]
      : []),
  ]);
}