@open-workspace/email 0.4.2 → 0.5.1
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-sender-intel.ts +5 -1
- 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 +52 -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 +391 -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 +12 -11
- 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 +758 -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 +119 -1816
- 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 +700 -0
- package/worker/mail/auth-headers.ts +57 -43
- package/worker/mail/auto-reply-routes.ts +260 -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-threading.ts +15 -2
- 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 +19 -8
- 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 +698 -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 +206 -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 +316 -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 +455 -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 +253 -0
- package/worker/mailbox/support.ts +416 -0
- package/worker/mcp/mail-action-tools.ts +161 -1
- 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
package/src/mail/reader-pane.tsx
CHANGED
|
@@ -37,17 +37,25 @@ import {
|
|
|
37
37
|
import { useState } from "react";
|
|
38
38
|
import type { ReactNode } from "react";
|
|
39
39
|
|
|
40
|
+
import { DRAFTS_FOLDER_ID } from "../../shared/folder-order";
|
|
41
|
+
import {
|
|
42
|
+
actionFolder,
|
|
43
|
+
conversationActionsIn,
|
|
44
|
+
} from "./conversation-actions-model";
|
|
40
45
|
import { ConversationView } from "./conversation-view";
|
|
41
46
|
import { folderShowsUnreadCount, orderedFolders } from "./mail-folders";
|
|
47
|
+
import { TranslationEnabled } from "./message-body";
|
|
42
48
|
import { useSenderActions } from "./sender-actions";
|
|
43
49
|
import type { SenderActions } from "./sender-actions";
|
|
44
50
|
import { ToolbarTooltip } from "./toolbar-tooltip";
|
|
51
|
+
import type { MessageDetail } from "./types";
|
|
45
52
|
import type { MailController } from "./use-mail-controller";
|
|
46
|
-
import {
|
|
53
|
+
import { useSenderIntel } from "./use-mail-data";
|
|
47
54
|
|
|
48
55
|
function CommandButton({
|
|
49
56
|
label,
|
|
50
57
|
shortLabel,
|
|
58
|
+
reserveLabel,
|
|
51
59
|
icon,
|
|
52
60
|
disabled,
|
|
53
61
|
destructive = false,
|
|
@@ -55,6 +63,8 @@ function CommandButton({
|
|
|
55
63
|
}: {
|
|
56
64
|
label: string;
|
|
57
65
|
shortLabel: string;
|
|
66
|
+
/** A label it changes to (Mark read, Mark unread): the button keeps the wider one's width. */
|
|
67
|
+
reserveLabel?: string;
|
|
58
68
|
icon: ReactNode;
|
|
59
69
|
disabled?: boolean;
|
|
60
70
|
destructive?: boolean;
|
|
@@ -74,14 +84,23 @@ function CommandButton({
|
|
|
74
84
|
)}
|
|
75
85
|
>
|
|
76
86
|
{icon}
|
|
77
|
-
|
|
87
|
+
{reserveLabel ? (
|
|
88
|
+
<span className="hidden text-left @lg/reader:inline-grid">
|
|
89
|
+
<span className="[grid-area:1/1]">{shortLabel}</span>
|
|
90
|
+
<span aria-hidden="true" className="invisible [grid-area:1/1]">
|
|
91
|
+
{reserveLabel}
|
|
92
|
+
</span>
|
|
93
|
+
</span>
|
|
94
|
+
) : (
|
|
95
|
+
<span className="hidden @lg/reader:inline">{shortLabel}</span>
|
|
96
|
+
)}
|
|
78
97
|
</Button>
|
|
79
98
|
</ToolbarTooltip>
|
|
80
99
|
);
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
function MoveMenu({ mail }: { mail: MailController }) {
|
|
84
|
-
const { folder, folders, conversation } = mail;
|
|
103
|
+
const { openConversationFolder: folder, folders, conversation } = mail;
|
|
85
104
|
|
|
86
105
|
// Where the conversation can move: Inbox (id null) and custom folders.
|
|
87
106
|
const targets: { id: string | null; name: string }[] = [
|
|
@@ -93,8 +112,7 @@ function MoveMenu({ mail }: { mail: MailController }) {
|
|
|
93
112
|
),
|
|
94
113
|
];
|
|
95
114
|
|
|
96
|
-
const disabled =
|
|
97
|
-
!conversation?.hasIncoming || mail.sharedActionPending || !targets.length;
|
|
115
|
+
const disabled = !conversation?.hasIncoming || !targets.length;
|
|
98
116
|
|
|
99
117
|
return (
|
|
100
118
|
<DropdownMenu>
|
|
@@ -133,8 +151,8 @@ function MoveMenu({ mail }: { mail: MailController }) {
|
|
|
133
151
|
);
|
|
134
152
|
}
|
|
135
153
|
|
|
136
|
-
function latestIncoming(
|
|
137
|
-
return [...
|
|
154
|
+
function latestIncoming(messages: MessageDetail[]) {
|
|
155
|
+
return [...messages]
|
|
138
156
|
.reverse()
|
|
139
157
|
.find((message) => message.direction === "incoming");
|
|
140
158
|
}
|
|
@@ -142,19 +160,20 @@ function latestIncoming(mail: MailController) {
|
|
|
142
160
|
/** Less frequent actions, mirroring what the list's selection toolbar offers. */
|
|
143
161
|
function MoreMenu({
|
|
144
162
|
mail,
|
|
163
|
+
messages,
|
|
145
164
|
actions,
|
|
146
165
|
}: {
|
|
147
166
|
mail: MailController;
|
|
167
|
+
messages: MessageDetail[];
|
|
148
168
|
actions: SenderActions;
|
|
149
169
|
}) {
|
|
150
|
-
const message = latestIncoming(
|
|
170
|
+
const message = latestIncoming(messages);
|
|
151
171
|
const reportable = mail.canReport;
|
|
152
172
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
173
|
+
const block = message?.sender?.block;
|
|
174
|
+
const canChangeBlock = mail.mailbox?.canOrganize && !block?.workspace;
|
|
156
175
|
|
|
157
|
-
|
|
176
|
+
if (!message || (!reportable && !canChangeBlock)) return null;
|
|
158
177
|
|
|
159
178
|
return (
|
|
160
179
|
<DropdownMenu>
|
|
@@ -165,7 +184,6 @@ function MoreMenu({
|
|
|
165
184
|
variant="ghost"
|
|
166
185
|
size="icon-sm"
|
|
167
186
|
aria-label="More conversation actions"
|
|
168
|
-
disabled={mail.sharedActionPending}
|
|
169
187
|
className="text-foreground/80"
|
|
170
188
|
/>
|
|
171
189
|
}
|
|
@@ -176,37 +194,32 @@ function MoreMenu({
|
|
|
176
194
|
<DropdownMenuContent align="start" className="w-60">
|
|
177
195
|
{reportable && (
|
|
178
196
|
<DropdownMenuGroup>
|
|
179
|
-
<DropdownMenuItem onClick={
|
|
197
|
+
<DropdownMenuItem onClick={mail.reportSpam}>
|
|
180
198
|
<OctagonAlert /> Report spam
|
|
181
199
|
</DropdownMenuItem>
|
|
182
200
|
</DropdownMenuGroup>
|
|
183
201
|
)}
|
|
184
|
-
{reportable &&
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
<
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
{reportable && canChangeBlock && <DropdownMenuSeparator />}
|
|
203
|
+
{canChangeBlock &&
|
|
204
|
+
(block ? (
|
|
205
|
+
<DropdownMenuItem onClick={() => actions.unblockSender(message)}>
|
|
206
|
+
<ShieldCheck />{" "}
|
|
207
|
+
<span className="truncate">Unblock “{block.pattern}”</span>
|
|
208
|
+
</DropdownMenuItem>
|
|
209
|
+
) : (
|
|
210
|
+
<DropdownMenuItem onClick={() => actions.open("block", message)}>
|
|
211
|
+
<ShieldBan />{" "}
|
|
212
|
+
<span className="truncate">
|
|
213
|
+
Block “{message.fromName || message.fromAddress}”
|
|
214
|
+
</span>
|
|
215
|
+
</DropdownMenuItem>
|
|
216
|
+
))}
|
|
198
217
|
</DropdownMenuContent>
|
|
199
218
|
</DropdownMenu>
|
|
200
219
|
);
|
|
201
220
|
}
|
|
202
221
|
|
|
203
|
-
function DeleteForeverButton({
|
|
204
|
-
mail,
|
|
205
|
-
onDelete,
|
|
206
|
-
}: {
|
|
207
|
-
mail: MailController;
|
|
208
|
-
onDelete: () => void;
|
|
209
|
-
}) {
|
|
222
|
+
function DeleteForeverButton({ onDelete }: { onDelete: () => void }) {
|
|
210
223
|
const [open, setOpen] = useState(false);
|
|
211
224
|
|
|
212
225
|
return (
|
|
@@ -216,7 +229,6 @@ function DeleteForeverButton({
|
|
|
216
229
|
shortLabel="Delete forever"
|
|
217
230
|
icon={<Trash2 />}
|
|
218
231
|
destructive
|
|
219
|
-
disabled={mail.sharedActionPending}
|
|
220
232
|
onClick={() => setOpen(true)}
|
|
221
233
|
/>
|
|
222
234
|
<AlertDialog open={open} onOpenChange={setOpen}>
|
|
@@ -249,26 +261,34 @@ function DeleteForeverButton({
|
|
|
249
261
|
|
|
250
262
|
function CommandBar({
|
|
251
263
|
mail,
|
|
264
|
+
messages,
|
|
252
265
|
actions,
|
|
253
266
|
}: {
|
|
254
267
|
mail: MailController;
|
|
268
|
+
messages: MessageDetail[];
|
|
255
269
|
actions: SenderActions;
|
|
256
270
|
}) {
|
|
257
|
-
const {
|
|
258
|
-
|
|
259
|
-
conversations,
|
|
260
|
-
conversationId,
|
|
261
|
-
sharedActionPending: pending,
|
|
262
|
-
} = mail;
|
|
271
|
+
const { conversations, conversationId, conversation } = mail;
|
|
272
|
+
const pending = !conversation;
|
|
263
273
|
|
|
264
|
-
|
|
274
|
+
// Until the conversation is read, the list's row places it: opened from
|
|
275
|
+
// the folder it is in, that folder's moves (Archive, Delete) apply. A
|
|
276
|
+
// Drafts row is a draft, whose conversation may be anywhere.
|
|
277
|
+
const placed =
|
|
278
|
+
Boolean(conversation) ||
|
|
279
|
+
(mail.folder !== DRAFTS_FOLDER_ID &&
|
|
280
|
+
!mail.listStale &&
|
|
281
|
+
conversations.some((item) => item.conversationId === conversationId));
|
|
265
282
|
|
|
266
|
-
const
|
|
267
|
-
|
|
283
|
+
const movePending = !placed;
|
|
284
|
+
|
|
285
|
+
const offered = conversationActionsIn(
|
|
286
|
+
actionFolder(mail.openConversationFolder)
|
|
268
287
|
);
|
|
269
288
|
|
|
270
|
-
const
|
|
271
|
-
const
|
|
289
|
+
const { index, previous, next, atLoadedEnd } = mail.position;
|
|
290
|
+
const { hasNextPage, isFetchingNextPage } = mail.conversationsQuery;
|
|
291
|
+
const nextUnloaded = atLoadedEnd && hasNextPage;
|
|
272
292
|
|
|
273
293
|
return (
|
|
274
294
|
<TooltipProvider delay={300}>
|
|
@@ -286,38 +306,28 @@ function CommandBar({
|
|
|
286
306
|
>
|
|
287
307
|
<ArrowLeft />
|
|
288
308
|
</Button>
|
|
289
|
-
{
|
|
309
|
+
{offered.archive ? (
|
|
290
310
|
<CommandButton
|
|
291
311
|
label="Archive conversation"
|
|
292
312
|
shortLabel="Archive"
|
|
293
313
|
icon={<Archive />}
|
|
294
|
-
disabled={
|
|
314
|
+
disabled={movePending}
|
|
295
315
|
onClick={mail.archive}
|
|
296
316
|
/>
|
|
297
317
|
) : (
|
|
298
318
|
<CommandButton
|
|
299
319
|
label={
|
|
300
|
-
|
|
320
|
+
offered.notSpam ? "Mark as not spam" : "Restore conversation"
|
|
301
321
|
}
|
|
302
|
-
shortLabel={
|
|
322
|
+
shortLabel={offered.notSpam ? "Not spam" : "Restore"}
|
|
303
323
|
icon={<Inbox />}
|
|
304
|
-
disabled={
|
|
305
|
-
onClick={
|
|
306
|
-
const message =
|
|
307
|
-
state === "spam" ? latestIncoming(mail) : undefined;
|
|
308
|
-
|
|
309
|
-
// "Not spam" also trusts the sender and teaches the classifier.
|
|
310
|
-
if (message) actions.markNotSpam(message);
|
|
311
|
-
else mail.restore();
|
|
312
|
-
}}
|
|
324
|
+
disabled={movePending}
|
|
325
|
+
onClick={offered.notSpam ? mail.notSpam : mail.restore}
|
|
313
326
|
/>
|
|
314
327
|
)}
|
|
315
|
-
{
|
|
328
|
+
{offered.deleteForever ? (
|
|
316
329
|
mail.deletePermanently ? (
|
|
317
|
-
<DeleteForeverButton
|
|
318
|
-
mail={mail}
|
|
319
|
-
onDelete={mail.deletePermanently}
|
|
320
|
-
/>
|
|
330
|
+
<DeleteForeverButton onDelete={mail.deletePermanently} />
|
|
321
331
|
) : null
|
|
322
332
|
) : (
|
|
323
333
|
<CommandButton
|
|
@@ -325,7 +335,7 @@ function CommandBar({
|
|
|
325
335
|
shortLabel="Delete"
|
|
326
336
|
icon={<Trash2 />}
|
|
327
337
|
destructive
|
|
328
|
-
disabled={
|
|
338
|
+
disabled={movePending}
|
|
329
339
|
onClick={mail.trash}
|
|
330
340
|
/>
|
|
331
341
|
)}
|
|
@@ -334,6 +344,7 @@ function CommandBar({
|
|
|
334
344
|
<CommandButton
|
|
335
345
|
label="Mark conversation as read"
|
|
336
346
|
shortLabel="Mark read"
|
|
347
|
+
reserveLabel="Mark unread"
|
|
337
348
|
icon={<MailOpen />}
|
|
338
349
|
disabled={pending}
|
|
339
350
|
onClick={mail.markRead}
|
|
@@ -342,13 +353,14 @@ function CommandBar({
|
|
|
342
353
|
<CommandButton
|
|
343
354
|
label="Mark conversation as unread"
|
|
344
355
|
shortLabel="Mark unread"
|
|
356
|
+
reserveLabel="Mark read"
|
|
345
357
|
icon={<Mail />}
|
|
346
358
|
disabled={pending}
|
|
347
359
|
onClick={mail.markUnread}
|
|
348
360
|
/>
|
|
349
361
|
) : null}
|
|
350
362
|
<MoveMenu mail={mail} />
|
|
351
|
-
<MoreMenu mail={mail} actions={actions} />
|
|
363
|
+
<MoreMenu mail={mail} messages={messages} actions={actions} />
|
|
352
364
|
|
|
353
365
|
<div className="ml-auto flex items-center gap-0.5 pl-2">
|
|
354
366
|
{index !== -1 && (
|
|
@@ -364,7 +376,8 @@ function CommandBar({
|
|
|
364
376
|
aria-label="Previous conversation"
|
|
365
377
|
disabled={!previous}
|
|
366
378
|
onClick={() =>
|
|
367
|
-
previous &&
|
|
379
|
+
previous &&
|
|
380
|
+
mail.openConversation(previous.conversationId, "replace")
|
|
368
381
|
}
|
|
369
382
|
>
|
|
370
383
|
<ChevronUp />
|
|
@@ -376,8 +389,11 @@ function CommandBar({
|
|
|
376
389
|
size="icon-sm"
|
|
377
390
|
className="size-7"
|
|
378
391
|
aria-label="Next conversation"
|
|
379
|
-
disabled={!next}
|
|
380
|
-
onClick={() =>
|
|
392
|
+
disabled={nextUnloaded ? isFetchingNextPage : !next}
|
|
393
|
+
onClick={() => {
|
|
394
|
+
if (next) mail.openConversation(next.conversationId, "replace");
|
|
395
|
+
else if (nextUnloaded) mail.openNextAfterLoading();
|
|
396
|
+
}}
|
|
381
397
|
>
|
|
382
398
|
<ChevronDown />
|
|
383
399
|
</Button>
|
|
@@ -488,47 +504,62 @@ export function ReaderPane({ mail }: { mail: MailController }) {
|
|
|
488
504
|
|
|
489
505
|
const senderActions = useSenderActions({
|
|
490
506
|
mailbox,
|
|
491
|
-
|
|
492
|
-
onOpenConversation: (id, folder) => mail.openConversation(id, folder),
|
|
507
|
+
onPlaces: mail.followOwnChange,
|
|
493
508
|
});
|
|
494
509
|
|
|
495
|
-
|
|
510
|
+
const messages = useSenderIntel(mailbox?.id, conversationMessages);
|
|
496
511
|
|
|
497
512
|
if (!conversationId) return <ReaderPlaceholder mail={mail} />;
|
|
498
513
|
const pages = conversationQuery.data?.pages;
|
|
499
514
|
|
|
500
515
|
return (
|
|
501
516
|
<div className="@container/reader flex min-h-0 flex-1 flex-col">
|
|
502
|
-
<CommandBar mail={mail} actions={senderActions} />
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
:
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
(
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
517
|
+
<CommandBar mail={mail} messages={messages} actions={senderActions} />
|
|
518
|
+
{/* One per conversation: it opens at the top, and its reply box and the draft it reopens are that conversation's. */}
|
|
519
|
+
<div
|
|
520
|
+
key={`${mailbox?.id ?? ""}:${conversationId}`}
|
|
521
|
+
className="min-h-0 flex-1 overflow-y-auto"
|
|
522
|
+
>
|
|
523
|
+
<TranslationEnabled value={conversation?.translationEnabled ?? false}>
|
|
524
|
+
<ConversationView
|
|
525
|
+
messages={messages}
|
|
526
|
+
matchId={mail.matchId}
|
|
527
|
+
matchQuoted={mail.matchQuoted}
|
|
528
|
+
pinnedId={mail.pinnedId}
|
|
529
|
+
openFromDrafts={mail.folder === DRAFTS_FOLDER_ID}
|
|
530
|
+
refreshing={conversationQuery.isFetching}
|
|
531
|
+
replyDraftSource={conversation?.replyDraftSource ?? null}
|
|
532
|
+
replyDraft={
|
|
533
|
+
mailbox?.canSend ? (conversation?.replyDraft ?? null) : null
|
|
534
|
+
}
|
|
535
|
+
messageCount={conversation?.messageCount ?? messages.length}
|
|
536
|
+
hasOlderMessages={Boolean(pages?.at(-1)?.nextCursor)}
|
|
537
|
+
loadingOlder={conversationQuery.isFetchingNextPage}
|
|
538
|
+
olderMessagesError={conversationQuery.isFetchNextPageError}
|
|
539
|
+
// The mailbox list confirms the URL's mailbox; until then a failed
|
|
540
|
+
// request may just be a stale link about to be redirected.
|
|
541
|
+
loading={
|
|
542
|
+
!mailbox || (!pages?.length && conversationQuery.isPending)
|
|
543
|
+
}
|
|
544
|
+
error={
|
|
545
|
+
pages?.length || !mailbox
|
|
546
|
+
? undefined
|
|
547
|
+
: conversationQuery.error?.message
|
|
548
|
+
}
|
|
549
|
+
summary={mail.conversations.find(
|
|
550
|
+
(item) => item.conversationId === conversationId
|
|
551
|
+
)}
|
|
552
|
+
mailbox={mailbox}
|
|
553
|
+
onRetry={() => void conversationQuery.refetch()}
|
|
554
|
+
onLoadOlder={() => void conversationQuery.fetchNextPage()}
|
|
555
|
+
onForward={mail.openForward}
|
|
556
|
+
onOpenConversation={(id) =>
|
|
557
|
+
mail.openConversation(id, "replace", "sent")
|
|
558
|
+
}
|
|
559
|
+
senderActions={senderActions}
|
|
560
|
+
reportable={mail.canReport}
|
|
561
|
+
/>
|
|
562
|
+
</TranslationEnabled>
|
|
532
563
|
</div>
|
|
533
564
|
{senderActions.dialogs}
|
|
534
565
|
</div>
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
cn,
|
|
11
11
|
} from "@open-workspace/core/ui";
|
|
12
12
|
import { Check, LoaderCircle } from "lucide-react";
|
|
13
|
-
import {
|
|
13
|
+
import { useRef, useState } from "react";
|
|
14
14
|
import type {
|
|
15
15
|
ClipboardEvent,
|
|
16
16
|
FocusEvent,
|
|
@@ -56,29 +56,37 @@ export function RecipientCombobox({
|
|
|
56
56
|
onChange: (value: RecipientFieldValue) => void;
|
|
57
57
|
}) {
|
|
58
58
|
const [focused, setFocused] = useState(false);
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
const [invalid, setInvalid] = useState(
|
|
61
|
+
() => parseComposerRecipients(value.input).invalidParts.length > 0
|
|
62
|
+
);
|
|
63
|
+
|
|
60
64
|
// Escape, or a click outside, hides the list until the text changes.
|
|
61
65
|
const [dismissed, setDismissed] = useState(false);
|
|
62
|
-
//
|
|
63
|
-
// first suggestion, which looks highlighted for that reason.
|
|
66
|
+
// Keep explicit selection separate from the default for a partial contact search.
|
|
64
67
|
const [highlighted, setHighlighted] = useState<ComposerRecipient>();
|
|
65
68
|
const chipsRef = useRef<HTMLDivElement>(null);
|
|
66
|
-
const
|
|
69
|
+
const typed = value.input.trim();
|
|
70
|
+
const typedRecipients = parseComposerRecipients(typed);
|
|
71
|
+
|
|
72
|
+
const complete =
|
|
73
|
+
typedRecipients.recipients.length > 0 &&
|
|
74
|
+
!typedRecipients.invalidParts.length;
|
|
75
|
+
|
|
76
|
+
const query = useDebouncedValue(typed, 120);
|
|
77
|
+
// Enter must only accept a suggestion for the text currently in the field.
|
|
78
|
+
const queryReady = Boolean(typed) && query === typed;
|
|
67
79
|
|
|
68
80
|
const suggestionsQuery = useRecipientSuggestions(
|
|
69
81
|
mailboxId,
|
|
70
82
|
query,
|
|
71
|
-
focused && !disabled &&
|
|
83
|
+
focused && !disabled && queryReady
|
|
72
84
|
);
|
|
73
85
|
|
|
74
|
-
const selected =
|
|
75
|
-
() =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
normalizeExternalEmailAddress(recipient.address)
|
|
79
|
-
)
|
|
80
|
-
),
|
|
81
|
-
[value.recipients]
|
|
86
|
+
const selected = new Set(
|
|
87
|
+
value.recipients.map((recipient) =>
|
|
88
|
+
normalizeExternalEmailAddress(recipient.address)
|
|
89
|
+
)
|
|
82
90
|
);
|
|
83
91
|
|
|
84
92
|
const suggestions = (suggestionsQuery.data?.suggestions ?? []).flatMap(
|
|
@@ -98,11 +106,7 @@ export function RecipientCombobox({
|
|
|
98
106
|
);
|
|
99
107
|
|
|
100
108
|
const open =
|
|
101
|
-
!disabled &&
|
|
102
|
-
focused &&
|
|
103
|
-
!dismissed &&
|
|
104
|
-
Boolean(value.input.trim()) &&
|
|
105
|
-
suggestions.length > 0;
|
|
109
|
+
!disabled && focused && !dismissed && queryReady && suggestions.length > 0;
|
|
106
110
|
|
|
107
111
|
function addRecipients(recipients: ComposerRecipient[]) {
|
|
108
112
|
if (!recipients.length) return;
|
|
@@ -131,12 +135,11 @@ export function RecipientCombobox({
|
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
function commitInput() {
|
|
134
|
-
const
|
|
135
|
-
const hasInvalid = parsed.invalidParts.length > 0;
|
|
138
|
+
const hasInvalid = typedRecipients.invalidParts.length > 0;
|
|
136
139
|
setInvalid(hasInvalid);
|
|
137
140
|
|
|
138
|
-
if (hasInvalid || !
|
|
139
|
-
addRecipients(
|
|
141
|
+
if (hasInvalid || !typedRecipients.recipients.length) return false;
|
|
142
|
+
addRecipients(typedRecipients.recipients);
|
|
140
143
|
|
|
141
144
|
return true;
|
|
142
145
|
}
|
|
@@ -156,8 +159,9 @@ export function RecipientCombobox({
|
|
|
156
159
|
return;
|
|
157
160
|
}
|
|
158
161
|
|
|
159
|
-
if (event.key === "Enter" && open)
|
|
160
|
-
|
|
162
|
+
if (event.key === "Enter" && open && highlighted) return;
|
|
163
|
+
|
|
164
|
+
if (event.key === "Enter" && open && !complete) {
|
|
161
165
|
event.preventDefault();
|
|
162
166
|
event.preventBaseUIHandler();
|
|
163
167
|
const [first] = suggestions;
|
|
@@ -175,6 +179,14 @@ export function RecipientCombobox({
|
|
|
175
179
|
) {
|
|
176
180
|
if (!value.input.trim()) return;
|
|
177
181
|
|
|
182
|
+
// Inside a quoted name ("Smith, Ann"), a comma is part of the name.
|
|
183
|
+
if (
|
|
184
|
+
(event.key === "," || event.key === ";") &&
|
|
185
|
+
(value.input.match(/"/gu)?.length ?? 0) % 2 === 1
|
|
186
|
+
) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
178
190
|
if (event.key === "Tab") {
|
|
179
191
|
// An address that does not parse keeps focus here, marked invalid.
|
|
180
192
|
if (!commitInput()) event.preventDefault();
|
|
@@ -192,7 +204,13 @@ export function RecipientCombobox({
|
|
|
192
204
|
const text = event.clipboardData.getData("text");
|
|
193
205
|
|
|
194
206
|
if (!RECIPIENT_SEPARATOR.test(text)) return;
|
|
195
|
-
const
|
|
207
|
+
const input = event.currentTarget;
|
|
208
|
+
const start = input.selectionStart ?? input.value.length;
|
|
209
|
+
const end = input.selectionEnd ?? start;
|
|
210
|
+
|
|
211
|
+
const parsed = parseComposerRecipients(
|
|
212
|
+
input.value.slice(0, start) + text + input.value.slice(end)
|
|
213
|
+
);
|
|
196
214
|
|
|
197
215
|
if (parsed.invalidParts.length || !parsed.recipients.length) {
|
|
198
216
|
setInvalid(parsed.invalidParts.length > 0);
|
|
@@ -231,17 +249,20 @@ export function RecipientCombobox({
|
|
|
231
249
|
inputValue={value.input}
|
|
232
250
|
open={open}
|
|
233
251
|
disabled={disabled}
|
|
234
|
-
autoHighlight
|
|
252
|
+
autoHighlight={!complete}
|
|
235
253
|
openOnInputClick={false}
|
|
236
254
|
isItemEqualToValue={(item, other) => item.address === other.address}
|
|
237
255
|
itemToStringLabel={(recipient) => recipient.name || recipient.address}
|
|
238
|
-
onItemHighlighted={(recipient) =>
|
|
256
|
+
onItemHighlighted={(recipient, details) =>
|
|
257
|
+
setHighlighted(details.reason === "none" ? undefined : recipient)
|
|
258
|
+
}
|
|
239
259
|
onOpenChange={(next) => setDismissed(!next)}
|
|
240
260
|
onInputValueChange={(next, details) => {
|
|
241
261
|
// The combobox clears its text when the list closes; typed addresses stay until committed.
|
|
242
262
|
if (details.reason !== "input-change") return;
|
|
243
263
|
setInvalid(false);
|
|
244
264
|
setDismissed(false);
|
|
265
|
+
setHighlighted(undefined);
|
|
245
266
|
onChange({ ...value, input: next });
|
|
246
267
|
}}
|
|
247
268
|
onValueChange={(next, details) => {
|
|
@@ -308,7 +329,9 @@ export function RecipientCombobox({
|
|
|
308
329
|
<ComboboxItem
|
|
309
330
|
key={suggestion.address}
|
|
310
331
|
value={suggestion}
|
|
311
|
-
data-default={
|
|
332
|
+
data-default={
|
|
333
|
+
(index === 0 && !complete && !highlighted) || undefined
|
|
334
|
+
}
|
|
312
335
|
className="group/suggestion data-default:bg-accent data-default:text-accent-foreground gap-2 rounded-lg px-2.5 py-2"
|
|
313
336
|
>
|
|
314
337
|
<Monogram
|
|
@@ -9,12 +9,14 @@ export function RecipientFieldRow({
|
|
|
9
9
|
label,
|
|
10
10
|
value,
|
|
11
11
|
onChange,
|
|
12
|
+
invalid,
|
|
12
13
|
disabled = false,
|
|
13
14
|
}: {
|
|
14
15
|
label: string;
|
|
15
16
|
value: string;
|
|
16
17
|
onChange: (value: string) => void;
|
|
17
18
|
disabled?: boolean;
|
|
19
|
+
invalid: boolean;
|
|
18
20
|
}) {
|
|
19
21
|
return (
|
|
20
22
|
<InputGroup className="h-11 rounded-none border-0 bg-transparent shadow-none has-[[data-slot=input-group-control]:focus-visible]:border-0 has-[[data-slot=input-group-control]:focus-visible]:ring-0 dark:bg-transparent">
|
|
@@ -24,6 +26,7 @@ export function RecipientFieldRow({
|
|
|
24
26
|
<InputGroupInput
|
|
25
27
|
className="px-2 dark:hover:bg-transparent"
|
|
26
28
|
aria-label={label}
|
|
29
|
+
aria-invalid={invalid}
|
|
27
30
|
value={value}
|
|
28
31
|
disabled={disabled}
|
|
29
32
|
onChange={(event) => onChange(event.target.value)}
|