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.

fix(email): auto-refresh newly-linked inbox avatar during post-link sync (#3844)

gbirmane9757a72954a
diff --git a/js/app/packages/queries/email/link.ts b/js/app/packages/queries/email/link.ts
index 05ba25f438..7c8b0c911d 100644
--- a/js/app/packages/queries/email/link.ts
+++ b/js/app/packages/queries/email/link.ts
@@ -11,12 +11,23 @@ import { emailKeys } from './keys';
const LINK_STALE_TIME = 5 * 60 * 1000;
+// A newly-linked inbox's avatar (`photo_url`) is written async, so poll the links
+// list while any inbox is still syncing; polling stops on its own once none are,
+// leaving steady-state/single-inbox users with no extra fetches.
+const LINK_SYNC_POLL_INTERVAL = 2_000;
+
+function isAnyInboxSyncing(data: ListLinksResponse | undefined): boolean {
+ return data?.links.some((link) => link.sync_status === 'SYNCING') ?? false;
+}
+
export function useEmailLinksQuery() {
return useQuery(() => ({
queryKey: emailKeys.links.queryKey,
queryFn: async () => throwOnErr(async () => await emailClient.getLinks()),
staleTime: LINK_STALE_TIME,
refetchOnWindowFocus: 'always',
+ refetchInterval: (query) =>
+ isAnyInboxSyncing(query.state.data) ? LINK_SYNC_POLL_INTERVAL : false,
}));
}