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.

feat(soup): Email invite badge (#1636)

Evan Hutnikcb3064b4fc72
diff --git a/js/app/packages/entity/src/components/Badges.tsx b/js/app/packages/entity/src/components/Badges.tsx
index acc369f09f..ab02d2d3da 100644
--- a/js/app/packages/entity/src/components/Badges.tsx
+++ b/js/app/packages/entity/src/components/Badges.tsx
@@ -29,6 +29,10 @@ export function DraftBadge() {
return <Badge class="text-accent-30 border-edge-muted px-2">draft</Badge>;
}
+export function InviteBadge() {
+ return <Badge class="text-accent-30 border-edge-muted px-2">invite</Badge>;
+}
+
export function ImportantBadge() {
return (
<Badge class="text-accent bg-accent/10 px-2 border-accent/10">
diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsx
index 0b626bd8f8..cdc42639b1 100644
--- a/js/app/packages/entity/src/composed/ListEntity.tsx
+++ b/js/app/packages/entity/src/composed/ListEntity.tsx
@@ -22,7 +22,7 @@ import { isSearchEntity } from '../types/search';
import { createEntityDraggable } from '../utils/draggable';
import { UnreadIndicator } from '../components/UnreadIndicator';
import { MultiSelectCheckbox } from '../components/MultiSelectCheckbox';
-import { DraftBadge, SharedBadge } from '../components/Badges';
+import { DraftBadge, InviteBadge, SharedBadge } from '../components/Badges';
import { DisplayName } from '../components/DisplayName';
import { useIsShared } from '../utils/shared';
import { ProjectBreadCrumb } from '../components/ProjectBreadCrumb';
@@ -110,7 +110,14 @@ function NarrowLayout(props: LayoutProps) {
<Match when={isEmailEntity(props.entity) && props.entity}>
{(entity) => (
<>
- <Show when={entity().isDraft}>
+ <Show
+ when={entity().isDraft}
+ fallback={
+ <Show when={entity().hasIcsAttachment}>
+ <InviteBadge />
+ </Show>
+ }
+ >
<DraftBadge />
</Show>
<span class="truncate">
@@ -261,7 +268,14 @@ function WideLayout(props: LayoutProps) {
}
>
<span class="w-(--title-width) truncate shrink-0 flex gap-2">
- <Show when={entity().isDraft}>
+ <Show
+ when={entity().isDraft}
+ fallback={
+ <Show when={entity().hasIcsAttachment}>
+ <InviteBadge />
+ </Show>
+ }
+ >
<DraftBadge />
</Show>
<span class="truncate">
diff --git a/js/app/packages/entity/src/index.ts b/js/app/packages/entity/src/index.ts
index 6c18fb2bb8..b4773aa31b 100644
--- a/js/app/packages/entity/src/index.ts
+++ b/js/app/packages/entity/src/index.ts
@@ -13,7 +13,7 @@ export { ListEntity } from './composed/ListEntity';
export { UnreadIndicator } from './components/UnreadIndicator';
export { MultiSelectCheckbox } from './components/MultiSelectCheckbox';
-export { DraftBadge, SharedBadge } from './components/Badges';
+export { DraftBadge, InviteBadge, SharedBadge } from './components/Badges';
export { DisplayName } from './components/DisplayName';
export { ProjectBreadCrumb } from './components/ProjectBreadCrumb';
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 4e5691ab87..75ac1b64e5 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -84,6 +84,7 @@ export type EmailEntity = EntityBase & {
senderEmail?: string;
senderName?: string;
labels?: SoupLabel[] | ApiLabel[];
+ hasIcsAttachment?: boolean;
};
export type ProjectEntity = EntityBase & {
diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.ts
index 5794bd8cd2..8845741dc1 100644
--- a/js/app/packages/queries/soup/transform-utils.ts
+++ b/js/app/packages/queries/soup/transform-utils.ts
@@ -391,6 +391,12 @@ export const mapSoupPageToEntityList: (
name: p.name ?? '',
}));
+ const hasIcsAttachment = item.data.attachments?.some(
+ (a) =>
+ a.mimeType === 'text/calendar' ||
+ a.filename?.toLowerCase().endsWith('.ics')
+ );
+
return {
...item.data,
createdAt: item.data.createdAt,
@@ -404,6 +410,7 @@ export const mapSoupPageToEntityList: (
frecencyScore: item.frecency_score,
viewedAt: item.data.viewedAt,
participants,
+ hasIcsAttachment,
};
}