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(mentions): fix fetch error showing email mentions as deleted (#2886)

Seamusfc6cd86cd7a2
diff --git a/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx b/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx
index bcc7ac6e99..1504d2c750 100644
--- a/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx
+++ b/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx
@@ -160,7 +160,7 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {
<Dialog.Portal>
<DialogWrapper>
<div class="flex flex-col overflow-hidden bracket-never text-sm">
- <div class="flex items-center justify-between gap-2 bg-panel px-2 h-[40px] border-b border-edge-muted shrink-0">
+ <div class="flex items-center justify-between gap-2 bg-panel px-2 h-10 border-b border-edge-muted shrink-0">
<Dialog.Title class="pl-2 text-sm font-medium">
Delete Property
</Dialog.Title>
diff --git a/js/app/packages/queries/preview/fetchers.ts b/js/app/packages/queries/preview/fetchers.ts
index 028654e590..72bf84ed13 100644
--- a/js/app/packages/queries/preview/fetchers.ts
+++ b/js/app/packages/queries/preview/fetchers.ts
@@ -266,68 +266,33 @@ async function fetchEmailPreviews(threadIds: string[]): Promise<PreviewItem[]> {
return results;
}
+function filterMapToId(items: Array<ItemEntity>, type: ItemEntity['type']) {
+ return items.filter((i) => i.type === type).map(({ id }) => id);
+}
+
+function doFetch(
+ fetcher: (ids: string[]) => Promise<PreviewItem[]>,
+ ids: string[]
+) {
+ if (ids.length > 0) return fetcher(ids);
+ return Promise.resolve([]);
+}
+
export async function fetchPreviewBatch(
items: ItemEntity[]
): Promise<Map<string, PreviewItem>> {
- const chatItems = items
- .filter((i) => i.type === 'chat' || !i.type)
- .map((i) => i.id);
-
- const documentItems = items
- .filter((i) => i.type === 'document' || !i.type)
- .map((i) => i.id);
-
- const channelItems = items
- .filter((i) => i.type === 'channel' || !i.type)
- .map((i) => i.id);
-
- const projectItems = items
- .filter((i) => i.type === 'project' || !i.type)
- .map((i) => i.id);
-
- const emailItems = items
- .filter((i) => i.type === 'email' || !i.type)
- .map((i) => i.id);
-
- const callItems = items
- .filter((i) => i.type === 'call' || !i.type)
- .map((i) => i.id);
-
- const [
- chatResults,
- documentResults,
- channelResults,
- projectResults,
- emailResults,
- ] = await Promise.all([
- chatItems.length > 0 ? fetchChatPreviews(chatItems) : Promise.resolve([]),
- callItems.length > 0 ? fetchCallPreviews(callItems) : Promise.resolve([]),
- documentItems.length > 0
- ? fetchDocumentPreviews(documentItems)
- : Promise.resolve([]),
- channelItems.length > 0
- ? fetchChannelPreviews(channelItems)
- : Promise.resolve([]),
- projectItems.length > 0
- ? fetchProjectPreviews(projectItems)
- : Promise.resolve([]),
- emailItems.length > 0
- ? fetchEmailPreviews(emailItems)
- : Promise.resolve([]),
+ const results = await Promise.all([
+ doFetch(fetchChatPreviews, filterMapToId(items, 'chat')),
+ doFetch(fetchCallPreviews, filterMapToId(items, 'call')),
+ doFetch(fetchChannelPreviews, filterMapToId(items, 'channel')),
+ doFetch(fetchDocumentPreviews, filterMapToId(items, 'document')),
+ doFetch(fetchProjectPreviews, filterMapToId(items, 'project')),
+ doFetch(fetchEmailPreviews, filterMapToId(items, 'email')),
]);
-
const resultMap = new Map<string, PreviewItem>();
-
- [
- ...chatResults,
- ...documentResults,
- ...channelResults,
- ...projectResults,
- ...emailResults,
- ].forEach((result) => {
+ results.flat().forEach((result) => {
resultMap.set(result.id, result);
});
-
return resultMap;
}
diff --git a/js/app/packages/queries/preview/preview.ts b/js/app/packages/queries/preview/preview.ts
index 3842e56df1..5bc9e14459 100644
--- a/js/app/packages/queries/preview/preview.ts
+++ b/js/app/packages/queries/preview/preview.ts
@@ -8,6 +8,7 @@ import { previewDataLoader } from './dataloader';
import { defaultNameTransform, fetchMessageContext } from './fetchers';
import { previewKeys } from './keys';
import type { AccessiblePreviewItem, ItemEntity, PreviewItem } from './types';
+import { LOCAL_ONLY } from '@core/constant/featureFlags';
// DEBUG VARS
const SIMULATE_BACKEND_DELAY_MS = 0;
@@ -19,20 +20,22 @@ function itemPreviewQueryOptions(item: ItemEntity) {
return {
queryKey: previewKeys.item(item.id).queryKey,
queryFn: async () => {
- // Simulate backend propagation delay for testing race conditions
- if (SIMULATE_BACKEND_DELAY_MS > 0) {
- await new Promise((resolve) =>
- setTimeout(resolve, SIMULATE_BACKEND_DELAY_MS)
- );
- }
-
- if (SIMULATE_FAILURE) {
- return Promise.resolve({
- id: item.id,
- type: item.type ?? DEFAULT_ITEM_TYPE,
- access: 'does_not_exist',
- loading: false,
- } as PreviewItem);
+ if (LOCAL_ONLY) {
+ // Simulate backend propagation delay for testing race conditions
+ if (SIMULATE_BACKEND_DELAY_MS > 0) {
+ await new Promise((resolve) =>
+ setTimeout(resolve, SIMULATE_BACKEND_DELAY_MS)
+ );
+ }
+
+ if (SIMULATE_FAILURE) {
+ return Promise.resolve({
+ id: item.id,
+ type: item.type ?? DEFAULT_ITEM_TYPE,
+ access: 'does_not_exist',
+ loading: false,
+ } as PreviewItem);
+ }
}
return previewDataLoader.load(item);