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(soup): graphql item not removed from list on done (#5504)

dev-rbf263ac1a5df9
diff --git a/apps/web/src/features/next-soup/utils.test.ts b/apps/web/src/features/next-soup/utils.test.ts
index 708442c602..ed4ec124cc 100644
--- a/apps/web/src/features/next-soup/utils.test.ts
+++ b/apps/web/src/features/next-soup/utils.test.ts
@@ -24,13 +24,14 @@ import type {
SplitManager,
} from '@components/app/split-layout/layoutManager';
import type { ChannelEntityTarget, EntityData } from '@entity';
-import type { UnifiedNotification } from '@notifications';
+import type { NotificationSource, UnifiedNotification } from '@notifications';
import { previewSourceEntityId } from './preview-history';
import {
getChannelEntityTarget,
getRowClickFallbackLocation,
openEntityInSplitFromUnifiedList,
preventDuplicatePreviewEntityOpen,
+ resolveMarkEntitiesDoneVariables,
} from './utils';
afterEach(() => {
@@ -111,6 +112,22 @@ const channelThreadRow = (opts?: {
...(opts?.notifications ? { notifications: () => opts.notifications } : {}),
}) as unknown as EntityData;
+describe('resolveMarkEntitiesDoneVariables', () => {
+ it('uses notifications attached to a GraphQL Soup entity', () => {
+ const notification = sendNotification('notification-1', 'message-1');
+ const notificationSource = {
+ notificationsByEntity: () => ({}),
+ } as NotificationSource;
+
+ expect(
+ resolveMarkEntitiesDoneVariables({
+ entities: [channelRow({ notifications: [notification] })],
+ notificationSource,
+ })
+ ).toEqual({ emailIds: [], notificationIds: ['notification-1'] });
+ });
+});
+
describe('preview duplicate navigation', () => {
it('rejects content owned by a different preview viewer and notifies', () => {
const controller = {
diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.ts
index 627c9b0c2d..aee3b1f210 100644
--- a/apps/web/src/features/next-soup/utils.ts
+++ b/apps/web/src/features/next-soup/utils.ts
@@ -1041,10 +1041,18 @@ export function resolveMarkEntitiesDoneVariables(args: {
} = args;
const emailIds = entities.filter((e) => e.type === 'email').map((e) => e.id);
const notificationIds = entities.flatMap((entity) => {
+ // GraphQL Soup rows carry their own notification edge. Prefer that edge
+ // over the global notification query, which may not have paged far enough
+ // to include this entity yet.
+ const attachedNotifications = isWithNotification(entity)
+ ? entity.notifications?.()
+ : undefined;
const notificationsForEntity =
+ attachedNotifications ??
notificationSource.notificationsByEntity()[
compositeEntity(toNotificationEntity(entity))
- ] ?? [];
+ ] ??
+ [];
return notificationsForMarkDone(
entity,