Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions apps/web/src/components/RightRail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ function RailContent({ kind, payload }: { kind: string; payload: unknown }) {
);
}
if (kind === "attachments" && Array.isArray(payload)) {
const attachments = payload.filter(isAttachmentView);
return (
<div className="space-y-2">
{payload.map((item, index) => {
const attachment = item as AttachmentView;
return <AttachmentActions key={attachment.id ?? index} attachment={attachment} />;
})}
{attachments.map((attachment, index) => (
<AttachmentActions key={attachment.id ?? index} attachment={attachment} />
))}
</div>
);
}
Expand Down Expand Up @@ -143,9 +143,7 @@ interface RoutePickerPayload {

function isRoutePickerPayload(value: unknown): value is RoutePickerPayload {
return (
isRecord(value) &&
Array.isArray(value.messageIds) &&
typeof value.fromQueueLabel === "string"
isRecord(value) && Array.isArray(value.messageIds) && typeof value.fromQueueLabel === "string"
);
}

Expand Down Expand Up @@ -598,6 +596,12 @@ function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
}

function isAttachmentView(value: unknown): value is AttachmentView {
return (
isRecord(value) && typeof value.filename === "string" && typeof value.mime_type === "string"
);
}

function formatNumber(value: number): string {
return new Intl.NumberFormat(undefined, { maximumFractionDigits: 0 }).format(value);
}
Expand Down
Loading