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): Scrolling issue (#1280)

Evan Hutnik00546da27d19
diff --git a/js/app/packages/queries/email/thread.ts b/js/app/packages/queries/email/thread.ts
index 30c53f60e6..e35fb9f6fb 100644
--- a/js/app/packages/queries/email/thread.ts
+++ b/js/app/packages/queries/email/thread.ts
@@ -149,26 +149,13 @@ export function useThreadQuery<Options extends UseThreadQueryOptions>(
type MarkThreadAsSeenParams = { threadId: string };
/**
- * Optimistically update thread and soup queries when marking as seen.
- * Does not await cancelQueries to avoid triggering suspense boundaries.
+ * Optimistically update soup queries when marking as seen.
+ * Note: We intentionally don't update the thread messages cache here.
+ * Doing so triggers Suspense boundaries which unmount/remount the email view,
+ * causing scroll position to reset. The is_read property isn't used in the
+ * email view anyway - only the soup/list view needs it.
*/
function threadSeenOnMutate(params: MarkThreadAsSeenParams): void {
- queryClient.cancelQueries({
- queryKey: emailKeys.threadMessages(params.threadId).queryKey,
- });
-
- queryClient.setQueryData<InfiniteData<Thread, number>>(
- emailKeys.threadMessages(params.threadId).queryKey,
- (old) =>
- old && {
- ...old,
- pages: old.pages.map((page) => ({
- ...page,
- is_read: true,
- })),
- }
- );
-
queryClient.setQueriesData<InfiniteData<SoupPage, unknown>>(
{ queryKey: queryKeys.all.dss },
(old) => {
@@ -213,14 +200,9 @@ export function useMarkThreadAsSeenMutation(
...withCallbacks<void, Error, MarkThreadAsSeenParams>(
{
onMutate: threadSeenOnMutate,
- onSuccess: (_, params) => {
- queryClient.invalidateQueries({
- queryKey: emailKeys.threadMessages(params.threadId).queryKey,
- });
- queryClient.invalidateQueries({
- queryKey: queryKeys.all.dss,
- });
- },
+ // Note: We intentionally don't invalidate thread messages in onSuccess.
+ // The optimistic update already sets isRead in soup, and invalidating
+ // thread messages triggers Suspense which resets scroll position.
},
callbacks
),