@open-workspace/email 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/alchemy/index.ts +130 -2
- package/drizzle/mailbox/0003_after_0_4_2.sql +180 -0
- package/drizzle/mailbox/meta/0003_snapshot.json +1507 -0
- package/drizzle/mailbox/meta/_journal.json +7 -0
- package/drizzle/mailbox/migrations.js +3 -1
- package/migrations/0002_after_0_4_2.sql +35 -0
- package/migrations/meta/0002_snapshot.json +807 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +23 -7
- package/shared/attachment-preview.ts +18 -8
- package/shared/folder-order.ts +31 -6
- package/shared/mail-headers.ts +3 -3
- package/shared/mail-html.ts +25 -0
- package/shared/mail-import.ts +0 -7
- package/shared/mail-received.ts +4 -4
- package/shared/mail-rule-actions.ts +47 -0
- package/shared/mail.ts +70 -4
- package/shared/office-preview.ts +0 -4
- package/shared/pdfjs-assets.ts +1 -3
- package/shared/rich-content.ts +35 -0
- package/shared/signature.ts +15 -0
- package/src/admin/address-auto-reply.tsx +49 -0
- package/src/admin/blocked-senders.tsx +86 -66
- package/src/admin/forward-destinations.tsx +140 -0
- package/src/admin/mail-archive.tsx +134 -0
- package/src/admin/team-signature.tsx +90 -0
- package/src/client.tsx +130 -16
- package/src/mail/attachment-preview-dialog.tsx +13 -5
- package/src/mail/auto-reply-banner.tsx +61 -0
- package/src/mail/blocked-senders.tsx +124 -91
- package/src/mail/compose-window-chrome.tsx +20 -8
- package/src/mail/compose-window.tsx +387 -365
- package/src/mail/composer-asset-bookmarks.ts +47 -12
- package/src/mail/composer-attachment-list.tsx +42 -17
- package/src/mail/composer-editor-document.ts +54 -10
- package/src/mail/composer-editor.tsx +44 -44
- package/src/mail/composer-link-text.ts +42 -0
- package/src/mail/composer-recipient-fields.tsx +25 -16
- package/src/mail/composer-recipients.ts +62 -16
- package/src/mail/composer-session.ts +107 -23
- package/src/mail/composer-toolbar.tsx +15 -1
- package/src/mail/composer-upload-client.ts +29 -1
- package/src/mail/composer-upload-progress.ts +2 -2
- package/src/mail/conversation-actions-model.ts +56 -0
- package/src/mail/conversation-list.tsx +263 -128
- package/src/mail/conversation-loading-skeleton.tsx +165 -90
- package/src/mail/conversation-message.tsx +257 -102
- package/src/mail/conversation-order.ts +12 -0
- package/src/mail/conversation-reply.tsx +313 -189
- package/src/mail/conversation-selection-toolbar.tsx +188 -143
- package/src/mail/conversation-view.tsx +315 -85
- package/src/mail/delivery-indicator.tsx +33 -12
- package/src/mail/draft-attachments.ts +194 -0
- package/src/mail/email-html-body.tsx +97 -53
- package/src/mail/folder-cleanup-bar.tsx +193 -0
- package/src/mail/folder-glyph.tsx +5 -0
- package/src/mail/folder-manager.tsx +71 -38
- package/src/mail/mail-app-bar.tsx +15 -3
- package/src/mail/mail-dock.tsx +19 -3
- package/src/mail/mail-focus.ts +48 -0
- package/src/mail/mail-folders.ts +14 -2
- package/src/mail/mail-layout.css +20 -0
- package/src/mail/mail-mailbox-sheet.tsx +22 -69
- package/src/mail/mail-nav-rail.tsx +7 -4
- package/src/mail/mail-nav.tsx +66 -46
- package/src/mail/mail-prefetch.ts +30 -9
- package/src/mail/mail-primitives.tsx +6 -4
- package/src/mail/mail-queries.ts +122 -20
- package/src/mail/mail-query-cache.ts +1085 -173
- package/src/mail/mail-search-params.ts +35 -0
- package/src/mail/mail-shell.tsx +32 -9
- package/src/mail/mailbox-ai-settings.tsx +56 -42
- package/src/mail/mailbox-realtime.tsx +4 -12
- package/src/mail/mailbox-rules.tsx +898 -0
- package/src/mail/message-actions.tsx +38 -26
- package/src/mail/message-attachments.tsx +20 -12
- package/src/mail/message-body.ts +53 -0
- package/src/mail/message-format.ts +8 -2
- package/src/mail/message-header.tsx +3 -1
- package/src/mail/message-translation.tsx +34 -67
- package/src/mail/original-message-sheet.tsx +63 -50
- package/src/mail/original-message.ts +6 -6
- package/src/mail/pane-splitter.tsx +3 -3
- package/src/mail/pdf-preview.tsx +70 -62
- package/src/mail/plain-message-text.tsx +28 -0
- package/src/mail/print-message.ts +31 -36
- package/src/mail/reader-pane.tsx +134 -103
- package/src/mail/recipient-combobox.tsx +52 -29
- package/src/mail/recipient-field-row.tsx +3 -0
- package/src/mail/rich-content.ts +128 -0
- package/src/mail/sanitize-email-html.ts +53 -32
- package/src/mail/sender-actions.tsx +48 -46
- package/src/mail/sender-authentication.tsx +1 -1
- package/src/mail/sender-dialogs.tsx +67 -43
- package/src/mail/sender-security.tsx +9 -10
- package/src/mail/signature.ts +43 -0
- package/src/mail/translation-html.ts +3 -3
- package/src/mail/types.ts +12 -0
- package/src/mail/use-composer-attachment-preflight.ts +23 -60
- package/src/mail/use-composer-core.ts +286 -0
- package/src/mail/use-composer-navigation.ts +120 -0
- package/src/mail/use-composer-submission.ts +154 -19
- package/src/mail/use-conversation-actions.ts +292 -0
- package/src/mail/use-conversation-position.ts +51 -0
- package/src/mail/use-conversation-selection.ts +192 -89
- package/src/mail/use-draft-autosave.ts +394 -0
- package/src/mail/use-drafts.ts +194 -0
- package/src/mail/use-mail-controller.ts +754 -213
- package/src/mail/use-mail-data.ts +210 -100
- package/src/mail/use-mail-safety.ts +19 -38
- package/src/mail/use-mail-send.ts +18 -6
- package/src/mail/use-pdf-translation.ts +1 -1
- package/src/mail/use-reply-cc.ts +61 -0
- package/src/mail/use-visible-message-read.ts +128 -64
- package/src/pwa/push-key.ts +18 -0
- package/src/pwa/push-subscription.ts +88 -26
- package/src/settings/auto-reply-editor.tsx +454 -0
- package/src/settings/auto-reply-page.tsx +59 -0
- package/src/settings/mail-apps-page.tsx +52 -43
- package/src/settings/notifications-page.tsx +82 -67
- package/src/settings/rich-content-editor.tsx +182 -0
- package/src/settings/settings-queries.ts +57 -0
- package/src/settings/signature-editor.tsx +142 -0
- package/src/settings/signature-page.tsx +70 -0
- package/worker/admin/blocked-sender-routes.ts +10 -16
- package/worker/backups/eml.ts +185 -0
- package/worker/backups/file-parts.ts +140 -0
- package/worker/backups/mail-backup.ts +644 -0
- package/worker/backups/settings-backup.ts +866 -0
- package/worker/backups/stream-eml.ts +73 -0
- package/worker/db/schema.ts +89 -5
- package/worker/jmap/attachment-blobs.ts +113 -0
- package/worker/jmap/blobs.ts +162 -0
- package/worker/jmap/draft-content.ts +42 -0
- package/worker/jmap/drafts.ts +70 -0
- package/worker/jmap/email-body.ts +152 -0
- package/worker/jmap/email-methods.ts +1223 -0
- package/worker/jmap/eventsource.ts +9 -8
- package/worker/jmap/import-methods.ts +205 -0
- package/worker/jmap/mailbox-methods.ts +187 -0
- package/worker/jmap/method-core.ts +379 -0
- package/worker/jmap/methods.ts +108 -1815
- package/worker/jmap/push-subscription-methods.ts +373 -0
- package/worker/jmap/push-types.ts +46 -2
- package/worker/jmap/push.ts +24 -31
- package/worker/jmap/routes.ts +144 -153
- package/worker/jmap/submission-methods.ts +395 -0
- package/worker/mail/access.ts +35 -12
- package/worker/mail/ai-classification.ts +2 -2
- package/worker/mail/archive-object.ts +96 -0
- package/worker/mail/archive-routes.ts +35 -0
- package/worker/mail/archive.ts +682 -0
- package/worker/mail/auth-headers.ts +48 -40
- package/worker/mail/auto-reply-routes.ts +255 -0
- package/worker/mail/auto-reply.ts +243 -0
- package/worker/mail/bimi.ts +53 -36
- package/worker/mail/bootstrap.ts +11 -3
- package/worker/mail/capabilities.ts +69 -0
- package/worker/mail/classification-signals.ts +1 -1
- package/worker/mail/confusables-data.ts +9 -0
- package/worker/mail/conversation-cursor.ts +6 -15
- package/worker/mail/delivery-events.ts +9 -7
- package/worker/mail/delivery-facts.ts +1 -1
- package/worker/mail/demo-routes.ts +3 -3
- package/worker/mail/doh.ts +3 -3
- package/worker/mail/download-links.ts +153 -0
- package/worker/mail/downloads.ts +2 -6
- package/worker/mail/draft-routes.ts +473 -0
- package/worker/mail/draft-sender.ts +54 -0
- package/worker/mail/edge-cache.ts +41 -55
- package/worker/mail/email-routing.ts +123 -0
- package/worker/mail/forward-destinations.ts +114 -0
- package/worker/mail/forward-downloads.ts +115 -0
- package/worker/mail/forward-html.ts +85 -0
- package/worker/mail/header-metadata.ts +2 -5
- package/worker/mail/impersonation.ts +102 -101
- package/worker/mail/import-routes.ts +29 -82
- package/worker/mail/import.ts +130 -0
- package/worker/mail/inbound-delivery.ts +6 -5
- package/worker/mail/inbound.ts +58 -28
- package/worker/mail/ip-intel.ts +8 -17
- package/worker/mail/isolate-cache.ts +1 -1
- package/worker/mail/mailbox-deletion.ts +33 -12
- package/worker/mail/mailbox-directory.ts +39 -65
- package/worker/mail/mailing-list.ts +29 -58
- package/worker/mail/message-security.ts +3 -3
- package/worker/mail/message-view.ts +12 -10
- package/worker/mail/office-conversion.ts +3 -5
- package/worker/mail/office-preview-container.ts +3 -8
- package/worker/mail/outbound-content.ts +139 -65
- package/worker/mail/outbound-delivery.ts +20 -17
- package/worker/mail/outbound-service.ts +34 -9
- package/worker/mail/outbound.ts +146 -75
- package/worker/mail/outgoing-context.ts +60 -30
- package/worker/mail/participants.ts +10 -15
- package/worker/mail/plain-body.ts +39 -0
- package/worker/mail/push-endpoint.ts +17 -0
- package/worker/mail/push-notifications.ts +53 -62
- package/worker/mail/quote-parser.ts +36 -24
- package/worker/mail/receive.ts +146 -39
- package/worker/mail/recipients.ts +1 -1
- package/worker/mail/remote-proxy.ts +3 -3
- package/worker/mail/repeat.ts +1 -1
- package/worker/mail/reply-plan.ts +124 -26
- package/worker/mail/rfc.ts +15 -7
- package/worker/mail/rich-content.ts +207 -0
- package/worker/mail/routes.ts +696 -304
- package/worker/mail/routing.ts +274 -0
- package/worker/mail/rules.ts +230 -0
- package/worker/mail/safety-routes.ts +88 -86
- package/worker/mail/schemas.ts +222 -31
- package/worker/mail/search.ts +25 -2
- package/worker/mail/security-settings.ts +4 -10
- package/worker/mail/send-message.ts +238 -0
- package/worker/mail/sender-intel.ts +12 -20
- package/worker/mail/signature-routes.ts +201 -0
- package/worker/mail/signatures.ts +195 -0
- package/worker/mail/spamhaus.ts +28 -16
- package/worker/mail/storage-keys.ts +35 -0
- package/worker/mail/unsubscribe.ts +19 -41
- package/worker/mail/uploads.ts +192 -80
- package/worker/mail/webhook-source.ts +3 -2
- package/worker/mail/workspace-safety.ts +194 -60
- package/worker/mailbox/demo.ts +13 -15
- package/worker/mailbox/email-index.ts +65 -35
- package/worker/mailbox/folder-model.ts +0 -20
- package/worker/mailbox/import-placement.ts +21 -36
- package/worker/mailbox/inbound-decision.ts +114 -0
- package/worker/mailbox/inbox-counts.ts +45 -25
- package/worker/mailbox/index.ts +756 -3201
- package/worker/mailbox/jmap-change-log.ts +195 -0
- package/worker/mailbox/jmap-email-rows.ts +186 -0
- package/worker/mailbox/jmap-mailboxes.ts +116 -0
- package/worker/mailbox/jmap-placement.ts +139 -0
- package/worker/mailbox/jmap-query-filter.ts +231 -0
- package/worker/mailbox/jmap-store.ts +167 -299
- package/worker/mailbox/mailbox-auto-reply.ts +301 -0
- package/worker/mailbox/mailbox-backup.ts +538 -0
- package/worker/mailbox/mailbox-drafts.ts +417 -0
- package/worker/mailbox/mailbox-folders.ts +242 -0
- package/worker/mailbox/mailbox-import.ts +450 -0
- package/worker/mailbox/mailbox-inbound.ts +934 -0
- package/worker/mailbox/mailbox-jmap.ts +294 -0
- package/worker/mailbox/mailbox-outbound.ts +413 -0
- package/worker/mailbox/mailbox-rules.ts +336 -0
- package/worker/mailbox/mailbox-senders.ts +294 -0
- package/worker/mailbox/mailbox-storage.ts +438 -0
- package/worker/mailbox/mailbox-views.ts +891 -0
- package/worker/mailbox/model.ts +1 -0
- package/worker/mailbox/office-preview-jobs.ts +59 -47
- package/worker/mailbox/placement.ts +933 -0
- package/worker/mailbox/restore-thread.ts +52 -0
- package/worker/mailbox/retention.ts +36 -0
- package/worker/mailbox/schema.ts +200 -1
- package/worker/mailbox/senders.ts +216 -178
- package/worker/mailbox/spam-undo-filing.ts +138 -0
- package/worker/mailbox/spam-undo.ts +240 -0
- package/worker/mailbox/support.ts +416 -0
- package/worker/mcp/mail-action-tools.ts +156 -0
- package/worker/mcp/mail-compose-tools.ts +7 -1
- package/worker/mcp/mail-safety-tools.ts +4 -4
- package/worker/module.ts +23 -4
- package/src/mail/use-compose-submission.ts +0 -208
- package/src/mail/use-reply-submission.ts +0 -114
- package/worker/mail/capped-body.ts +0 -36
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Button, cn } from "@open-workspace/core/ui";
|
|
2
2
|
import { ChevronDown, Ellipsis, Eye, Paperclip, RotateCw } from "lucide-react";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useLayoutEffect, useState } from "react";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
4
5
|
|
|
5
6
|
import { DeliveryIndicator } from "./delivery-indicator";
|
|
7
|
+
import { MessageBody } from "./email-html-body";
|
|
6
8
|
import { canRetry, MessageActions } from "./message-actions";
|
|
7
9
|
import type { MessageHandlers } from "./message-actions";
|
|
8
10
|
import { MessageAttachments } from "./message-attachments";
|
|
11
|
+
import { useMessageBody } from "./message-body";
|
|
9
12
|
import {
|
|
10
13
|
compactDate,
|
|
11
14
|
fullDate,
|
|
@@ -16,11 +19,8 @@ import {
|
|
|
16
19
|
shortDate,
|
|
17
20
|
} from "./message-format";
|
|
18
21
|
import { MessageDetails, SenderLine } from "./message-header";
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
TranslationBar,
|
|
22
|
-
useMessageTranslation,
|
|
23
|
-
} from "./message-translation";
|
|
22
|
+
import { TranslationBar, useMessageTranslation } from "./message-translation";
|
|
23
|
+
import { PlainMessageText } from "./plain-message-text";
|
|
24
24
|
import {
|
|
25
25
|
SenderAvatar,
|
|
26
26
|
SenderSecurityBanner,
|
|
@@ -38,6 +38,7 @@ export function ConversationMessage({
|
|
|
38
38
|
message,
|
|
39
39
|
mailbox,
|
|
40
40
|
defaultExpanded,
|
|
41
|
+
searchTarget,
|
|
41
42
|
collapsible,
|
|
42
43
|
showViewedBy,
|
|
43
44
|
resendPending,
|
|
@@ -46,54 +47,188 @@ export function ConversationMessage({
|
|
|
46
47
|
message: MessageDetail;
|
|
47
48
|
mailbox?: Mailbox;
|
|
48
49
|
defaultExpanded: boolean;
|
|
50
|
+
searchTarget?: "message" | "quote";
|
|
49
51
|
collapsible: boolean;
|
|
50
52
|
showViewedBy: boolean;
|
|
51
53
|
resendPending: boolean;
|
|
52
54
|
handlers: MessageHandlers;
|
|
53
55
|
}) {
|
|
54
56
|
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
57
|
+
// Expanded by a click, it fades in; reading it doesn't.
|
|
58
|
+
const [clicked, setClicked] = useState(false);
|
|
55
59
|
const shown = expanded || !collapsible;
|
|
56
60
|
const outgoing = message.direction === "outgoing";
|
|
57
61
|
|
|
58
62
|
const visibilityRef = useVisibleMessageRead({
|
|
59
|
-
enabled: !
|
|
63
|
+
enabled: !outgoing || showViewedBy,
|
|
64
|
+
read: message.isRead,
|
|
60
65
|
messageId: message.id,
|
|
61
66
|
onVisible: handlers.onViewed,
|
|
62
67
|
});
|
|
63
68
|
|
|
69
|
+
useLayoutEffect(() => {
|
|
70
|
+
if (!searchTarget) return;
|
|
71
|
+
const section = visibilityRef.current;
|
|
72
|
+
|
|
73
|
+
const quote =
|
|
74
|
+
searchTarget === "quote" && section?.querySelector("[data-search-quote]");
|
|
75
|
+
|
|
76
|
+
(quote || section)?.scrollIntoView({ block: "start" });
|
|
77
|
+
}, [searchTarget, visibilityRef]);
|
|
78
|
+
|
|
64
79
|
return (
|
|
65
80
|
<section
|
|
66
81
|
ref={visibilityRef}
|
|
67
82
|
data-message-id={message.id}
|
|
68
83
|
data-expanded={shown || undefined}
|
|
69
|
-
className=
|
|
84
|
+
className={messageSectionClassName}
|
|
70
85
|
>
|
|
71
|
-
{outgoing &&
|
|
72
|
-
<span
|
|
73
|
-
aria-hidden="true"
|
|
74
|
-
className="bg-primary/55 absolute inset-y-0 left-0 w-0.5"
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
86
|
+
{outgoing && <OutgoingMark />}
|
|
77
87
|
{shown ? (
|
|
78
88
|
<ExpandedMessage
|
|
79
89
|
message={message}
|
|
80
90
|
mailbox={mailbox}
|
|
81
91
|
showViewedBy={showViewedBy}
|
|
92
|
+
expandQuote={searchTarget === "quote"}
|
|
82
93
|
resendPending={resendPending}
|
|
83
94
|
handlers={handlers}
|
|
95
|
+
// Opened by a click, it fades in; as the conversation opens, it
|
|
96
|
+
// takes the loading header's place without a blink.
|
|
97
|
+
fadeIn={clicked}
|
|
84
98
|
onCollapse={collapsible ? () => setExpanded(false) : undefined}
|
|
85
99
|
/>
|
|
86
100
|
) : (
|
|
87
101
|
<CollapsedMessage
|
|
88
102
|
message={message}
|
|
89
103
|
mailbox={mailbox}
|
|
90
|
-
onExpand={() =>
|
|
104
|
+
onExpand={() => {
|
|
105
|
+
setExpanded(true);
|
|
106
|
+
setClicked(true);
|
|
107
|
+
}}
|
|
91
108
|
/>
|
|
92
109
|
)}
|
|
93
110
|
</section>
|
|
94
111
|
);
|
|
95
112
|
}
|
|
96
113
|
|
|
114
|
+
/** The conversation's subject over its messages, shared with the loading conversation. */
|
|
115
|
+
export function ConversationHeading({
|
|
116
|
+
subject,
|
|
117
|
+
messageCount,
|
|
118
|
+
}: {
|
|
119
|
+
subject: string;
|
|
120
|
+
messageCount: number;
|
|
121
|
+
}) {
|
|
122
|
+
return (
|
|
123
|
+
<header className="px-4 pt-5 pb-4 sm:px-6 sm:pt-6">
|
|
124
|
+
<h1 className="text-[1.3125rem] leading-[1.3] font-semibold tracking-[-0.018em] text-balance [overflow-wrap:anywhere]">
|
|
125
|
+
{subject}
|
|
126
|
+
</h1>
|
|
127
|
+
{messageCount > 1 && (
|
|
128
|
+
<p className="text-muted-foreground mt-1 text-xs">
|
|
129
|
+
{messageCount} messages
|
|
130
|
+
</p>
|
|
131
|
+
)}
|
|
132
|
+
</header>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A message's place in the stack, shared with the loading conversation. */
|
|
137
|
+
export const messageSectionClassName =
|
|
138
|
+
"group/message border-border relative border-t first:border-t-0";
|
|
139
|
+
|
|
140
|
+
/** The body column under an expanded message's header. */
|
|
141
|
+
export const messageBodyColumnClassName = "mt-4 min-w-0 @lg/reader:pl-12";
|
|
142
|
+
|
|
143
|
+
/** The recipients line: a button that opens the details, or text while loading. */
|
|
144
|
+
export const recipientsLineClassName =
|
|
145
|
+
"text-muted-foreground -mt-0.5 flex max-w-full min-w-0 items-center gap-1 rounded-sm text-left text-xs";
|
|
146
|
+
|
|
147
|
+
/** Marks a message the mailbox sent. */
|
|
148
|
+
export function OutgoingMark() {
|
|
149
|
+
return (
|
|
150
|
+
<span
|
|
151
|
+
aria-hidden="true"
|
|
152
|
+
className="bg-primary/55 absolute inset-y-0 left-0 w-0.5"
|
|
153
|
+
/>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* An expanded message's frame: the avatar, the sender line with the date
|
|
159
|
+
* and actions, the recipients, then what follows. The loading conversation
|
|
160
|
+
* fills the same frame from the list's row, so nothing moves when the
|
|
161
|
+
* message arrives.
|
|
162
|
+
*/
|
|
163
|
+
export function ExpandedMessageFrame({
|
|
164
|
+
avatar,
|
|
165
|
+
sender,
|
|
166
|
+
date,
|
|
167
|
+
actions,
|
|
168
|
+
recipients,
|
|
169
|
+
fadeIn = false,
|
|
170
|
+
children,
|
|
171
|
+
}: {
|
|
172
|
+
avatar: ReactNode;
|
|
173
|
+
sender: ReactNode;
|
|
174
|
+
date: ReactNode;
|
|
175
|
+
actions: ReactNode;
|
|
176
|
+
recipients: ReactNode;
|
|
177
|
+
fadeIn?: boolean;
|
|
178
|
+
children: ReactNode;
|
|
179
|
+
}) {
|
|
180
|
+
return (
|
|
181
|
+
<div className={cn("px-4 pt-4 pb-5 sm:px-6", fadeIn && "animate-fade-in")}>
|
|
182
|
+
<header className="flex items-start gap-3">
|
|
183
|
+
{avatar}
|
|
184
|
+
<div className="min-w-0 flex-1">
|
|
185
|
+
<div className="flex min-h-7 items-center gap-2">
|
|
186
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
187
|
+
{sender}
|
|
188
|
+
</div>
|
|
189
|
+
<span className="text-muted-foreground flex shrink-0 items-center gap-2.5 text-xs">
|
|
190
|
+
{date}
|
|
191
|
+
</span>
|
|
192
|
+
{actions}
|
|
193
|
+
</div>
|
|
194
|
+
{recipients}
|
|
195
|
+
</div>
|
|
196
|
+
</header>
|
|
197
|
+
{children}
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** The sender's avatar in an expanded message's header. */
|
|
203
|
+
export function HeaderAvatar({
|
|
204
|
+
sender,
|
|
205
|
+
logoUrl,
|
|
206
|
+
}: {
|
|
207
|
+
sender: string;
|
|
208
|
+
logoUrl: string | null;
|
|
209
|
+
}) {
|
|
210
|
+
return (
|
|
211
|
+
<SenderAvatar
|
|
212
|
+
name={sender}
|
|
213
|
+
logoUrl={logoUrl}
|
|
214
|
+
className="mt-0.5 size-9 rounded-full text-[12px]"
|
|
215
|
+
/>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The message's time in its header. */
|
|
220
|
+
export function HeaderDate({ value }: { value: string }) {
|
|
221
|
+
return (
|
|
222
|
+
<time
|
|
223
|
+
dateTime={new Date(value).toISOString()}
|
|
224
|
+
title={fullDate(value)}
|
|
225
|
+
className="tabular-nums"
|
|
226
|
+
>
|
|
227
|
+
{shortDate(value)}
|
|
228
|
+
</time>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
97
232
|
function CollapsedMessage({
|
|
98
233
|
message,
|
|
99
234
|
mailbox,
|
|
@@ -152,6 +287,8 @@ function ExpandedMessage({
|
|
|
152
287
|
showViewedBy,
|
|
153
288
|
resendPending,
|
|
154
289
|
handlers,
|
|
290
|
+
fadeIn,
|
|
291
|
+
expandQuote,
|
|
155
292
|
onCollapse,
|
|
156
293
|
}: {
|
|
157
294
|
message: MessageDetail;
|
|
@@ -159,10 +296,14 @@ function ExpandedMessage({
|
|
|
159
296
|
showViewedBy: boolean;
|
|
160
297
|
resendPending: boolean;
|
|
161
298
|
handlers: MessageHandlers;
|
|
299
|
+
fadeIn: boolean;
|
|
300
|
+
expandQuote: boolean;
|
|
162
301
|
onCollapse?: () => void;
|
|
163
302
|
}) {
|
|
164
303
|
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
165
|
-
const
|
|
304
|
+
const [quoteOpen, setQuoteOpen] = useState(expandQuote);
|
|
305
|
+
const { body, ready, quoteInBody } = useMessageBody(mailbox?.id, message);
|
|
306
|
+
const translation = useMessageTranslation(message, body, ready, mailbox?.id);
|
|
166
307
|
const sender = senderName(message);
|
|
167
308
|
const own = isOwnAddress(message.fromAddress, mailbox);
|
|
168
309
|
const outgoing = message.direction === "outgoing";
|
|
@@ -172,68 +313,60 @@ function ExpandedMessage({
|
|
|
172
313
|
: [];
|
|
173
314
|
|
|
174
315
|
return (
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
316
|
+
<ExpandedMessageFrame
|
|
317
|
+
fadeIn={fadeIn}
|
|
318
|
+
avatar={<HeaderAvatar sender={sender} logoUrl={message.senderLogoUrl} />}
|
|
319
|
+
sender={
|
|
320
|
+
<>
|
|
321
|
+
<SenderLine
|
|
322
|
+
message={message}
|
|
323
|
+
sender={sender}
|
|
324
|
+
own={own}
|
|
325
|
+
onCollapse={onCollapse}
|
|
326
|
+
/>
|
|
327
|
+
<SubscriptionAction
|
|
328
|
+
message={message}
|
|
329
|
+
onUnsubscribe={handlers.sender?.onUnsubscribe}
|
|
330
|
+
/>
|
|
331
|
+
</>
|
|
332
|
+
}
|
|
333
|
+
date={
|
|
334
|
+
<>
|
|
335
|
+
{outgoing && <DeliveryIndicator message={message} />}
|
|
336
|
+
<HeaderDate value={message.timelineAt} />
|
|
337
|
+
</>
|
|
338
|
+
}
|
|
339
|
+
actions={
|
|
340
|
+
<MessageActions
|
|
341
|
+
message={message}
|
|
342
|
+
translation={translation}
|
|
343
|
+
resendPending={resendPending}
|
|
344
|
+
handlers={handlers}
|
|
181
345
|
/>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<MessageActions
|
|
207
|
-
message={message}
|
|
208
|
-
canForward={Boolean(mailbox?.canSend)}
|
|
209
|
-
mailboxId={mailbox?.id}
|
|
210
|
-
translation={translation}
|
|
211
|
-
resendPending={resendPending}
|
|
212
|
-
handlers={handlers}
|
|
213
|
-
/>
|
|
214
|
-
</div>
|
|
215
|
-
<button
|
|
216
|
-
type="button"
|
|
217
|
-
aria-expanded={detailsOpen}
|
|
218
|
-
onClick={() => setDetailsOpen((open) => !open)}
|
|
219
|
-
className="text-muted-foreground hover:text-foreground focus-visible:ring-ring -mt-0.5 flex max-w-full min-w-0 items-center gap-1 rounded-sm text-left text-xs outline-none focus-visible:ring-2"
|
|
220
|
-
>
|
|
221
|
-
<span className="truncate">
|
|
222
|
-
{recipientSummary(message, mailbox)}
|
|
223
|
-
</span>
|
|
224
|
-
<ChevronDown
|
|
225
|
-
className={cn(
|
|
226
|
-
"size-3 shrink-0 transition-transform",
|
|
227
|
-
detailsOpen && "rotate-180"
|
|
228
|
-
)}
|
|
229
|
-
/>
|
|
230
|
-
<span className="sr-only">
|
|
231
|
-
{detailsOpen ? "Hide message details" : "Show message details"}
|
|
232
|
-
</span>
|
|
233
|
-
</button>
|
|
234
|
-
</div>
|
|
235
|
-
</header>
|
|
236
|
-
|
|
346
|
+
}
|
|
347
|
+
recipients={
|
|
348
|
+
<button
|
|
349
|
+
type="button"
|
|
350
|
+
aria-expanded={detailsOpen}
|
|
351
|
+
onClick={() => setDetailsOpen((open) => !open)}
|
|
352
|
+
className={cn(
|
|
353
|
+
recipientsLineClassName,
|
|
354
|
+
"hover:text-foreground focus-visible:ring-ring outline-none focus-visible:ring-2"
|
|
355
|
+
)}
|
|
356
|
+
>
|
|
357
|
+
<span className="truncate">{recipientSummary(message, mailbox)}</span>
|
|
358
|
+
<ChevronDown
|
|
359
|
+
className={cn(
|
|
360
|
+
"size-3 shrink-0 transition-transform",
|
|
361
|
+
detailsOpen && "rotate-180"
|
|
362
|
+
)}
|
|
363
|
+
/>
|
|
364
|
+
<span className="sr-only">
|
|
365
|
+
{detailsOpen ? "Hide message details" : "Show message details"}
|
|
366
|
+
</span>
|
|
367
|
+
</button>
|
|
368
|
+
}
|
|
369
|
+
>
|
|
237
370
|
{detailsOpen && (
|
|
238
371
|
<MessageDetails
|
|
239
372
|
message={message}
|
|
@@ -255,18 +388,27 @@ function ExpandedMessage({
|
|
|
255
388
|
<RetryNotice
|
|
256
389
|
message={message}
|
|
257
390
|
pending={resendPending}
|
|
258
|
-
onResend={handlers.
|
|
391
|
+
onResend={handlers.send?.resend}
|
|
259
392
|
/>
|
|
260
393
|
)}
|
|
261
394
|
|
|
262
|
-
<div className=
|
|
395
|
+
<div className={messageBodyColumnClassName}>
|
|
263
396
|
<TranslationBar translation={translation} />
|
|
264
397
|
<MessageBody
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
398
|
+
subject={message.subject}
|
|
399
|
+
body={translation.body}
|
|
400
|
+
ready={ready}
|
|
401
|
+
hideQuote={quoteInBody && !quoteOpen}
|
|
402
|
+
focusQuote={quoteInBody && expandQuote && quoteOpen}
|
|
268
403
|
/>
|
|
269
|
-
{message.quotedText &&
|
|
404
|
+
{message.quotedText && (
|
|
405
|
+
<QuotedText
|
|
406
|
+
text={quoteInBody ? null : message.quotedText}
|
|
407
|
+
open={quoteOpen}
|
|
408
|
+
onToggle={() => setQuoteOpen(!quoteOpen)}
|
|
409
|
+
searchTarget={expandQuote}
|
|
410
|
+
/>
|
|
411
|
+
)}
|
|
270
412
|
<MessageAttachments
|
|
271
413
|
messageId={message.id}
|
|
272
414
|
mailboxId={mailbox?.id}
|
|
@@ -279,7 +421,7 @@ function ExpandedMessage({
|
|
|
279
421
|
</p>
|
|
280
422
|
)}
|
|
281
423
|
</div>
|
|
282
|
-
</
|
|
424
|
+
</ExpandedMessageFrame>
|
|
283
425
|
);
|
|
284
426
|
}
|
|
285
427
|
|
|
@@ -290,7 +432,7 @@ function RetryNotice({
|
|
|
290
432
|
}: {
|
|
291
433
|
message: MessageDetail;
|
|
292
434
|
pending: boolean;
|
|
293
|
-
onResend:
|
|
435
|
+
onResend?: (message: MessageDetail) => void;
|
|
294
436
|
}) {
|
|
295
437
|
const failed = message.transportState === "failed";
|
|
296
438
|
|
|
@@ -308,37 +450,50 @@ function RetryNotice({
|
|
|
308
450
|
? message.transportError || "This message could not be sent."
|
|
309
451
|
: "Submission was not confirmed. Sending again may deliver a duplicate."}
|
|
310
452
|
</span>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
453
|
+
{onResend && (
|
|
454
|
+
<Button
|
|
455
|
+
type="button"
|
|
456
|
+
size="xs"
|
|
457
|
+
variant="outline"
|
|
458
|
+
disabled={pending}
|
|
459
|
+
onClick={() => onResend(message)}
|
|
460
|
+
>
|
|
461
|
+
<RotateCw className={cn(pending && "animate-spin")} />
|
|
462
|
+
{failed ? "Retry" : "Send again"}
|
|
463
|
+
</Button>
|
|
464
|
+
)}
|
|
321
465
|
</div>
|
|
322
466
|
);
|
|
323
467
|
}
|
|
324
468
|
|
|
325
|
-
function QuotedText({
|
|
326
|
-
|
|
327
|
-
|
|
469
|
+
function QuotedText({
|
|
470
|
+
text,
|
|
471
|
+
open,
|
|
472
|
+
onToggle,
|
|
473
|
+
searchTarget,
|
|
474
|
+
}: {
|
|
475
|
+
text: string | null;
|
|
476
|
+
open: boolean;
|
|
477
|
+
onToggle: () => void;
|
|
478
|
+
searchTarget: boolean;
|
|
479
|
+
}) {
|
|
328
480
|
return (
|
|
329
481
|
<div className="mt-3">
|
|
330
482
|
<button
|
|
331
483
|
type="button"
|
|
332
484
|
aria-expanded={open}
|
|
333
|
-
onClick={
|
|
485
|
+
onClick={onToggle}
|
|
334
486
|
className="bg-muted text-muted-foreground hover:bg-accent hover:text-foreground focus-visible:ring-ring inline-flex h-5 items-center gap-1 rounded-full px-2 text-[11px] font-medium transition-colors outline-none focus-visible:ring-2"
|
|
335
487
|
>
|
|
336
488
|
<Ellipsis className="size-3.5" />
|
|
337
489
|
{open ? "Hide quoted text" : "Show quoted text"}
|
|
338
490
|
</button>
|
|
339
|
-
{open && (
|
|
340
|
-
<blockquote
|
|
341
|
-
{
|
|
491
|
+
{open && text && (
|
|
492
|
+
<blockquote
|
|
493
|
+
data-search-quote={searchTarget || undefined}
|
|
494
|
+
className="border-border text-muted-foreground mt-2 max-h-80 max-w-[72ch] overflow-auto border-l-2 pl-3 text-[13px] leading-[1.6] whitespace-pre-wrap"
|
|
495
|
+
>
|
|
496
|
+
<PlainMessageText text={text} />
|
|
342
497
|
</blockquote>
|
|
343
498
|
)}
|
|
344
499
|
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConversationSummary } from "./types";
|
|
2
|
+
|
|
3
|
+
/** Newest first, as lists are ordered (`timeline_at desc, latest_email_id desc`). */
|
|
4
|
+
export function newerThan(
|
|
5
|
+
left: ConversationSummary,
|
|
6
|
+
right: ConversationSummary
|
|
7
|
+
) {
|
|
8
|
+
return (
|
|
9
|
+
left.timelineAt > right.timelineAt ||
|
|
10
|
+
(left.timelineAt === right.timelineAt && left.id > right.id)
|
|
11
|
+
);
|
|
12
|
+
}
|