@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,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Button,
|
|
3
3
|
Checkbox,
|
|
4
|
+
PlaceholderFrame,
|
|
5
|
+
restoreFocus,
|
|
4
6
|
Skeleton,
|
|
7
|
+
StaleContent,
|
|
8
|
+
useDelayedPending,
|
|
5
9
|
ToggleGroup,
|
|
6
10
|
ToggleGroupItem,
|
|
7
11
|
TooltipProvider,
|
|
@@ -16,10 +20,12 @@ import {
|
|
|
16
20
|
RotateCw,
|
|
17
21
|
SearchX,
|
|
18
22
|
} from "lucide-react";
|
|
19
|
-
import { useEffect, useRef } from "react";
|
|
23
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
20
24
|
import type { ReactNode } from "react";
|
|
21
25
|
|
|
26
|
+
import { DRAFTS_FOLDER_ID } from "../../shared/folder-order";
|
|
22
27
|
import { ConversationSelectionToolbar } from "./conversation-selection-toolbar";
|
|
28
|
+
import { FolderCleanupBar } from "./folder-cleanup-bar";
|
|
23
29
|
import { SearchField } from "./mail-app-bar";
|
|
24
30
|
import { folderShowsUnreadCount } from "./mail-folders";
|
|
25
31
|
import { MailboxCaption } from "./mail-mailbox-sheet";
|
|
@@ -118,6 +124,7 @@ function ConversationRow({
|
|
|
118
124
|
|
|
119
125
|
return (
|
|
120
126
|
<li
|
|
127
|
+
data-conversation-id={conversation.conversationId}
|
|
121
128
|
className={cn(
|
|
122
129
|
"mail-row group relative border-b border-(--rule) transition-colors duration-100",
|
|
123
130
|
"before:bg-primary before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:opacity-0",
|
|
@@ -158,7 +165,8 @@ function ConversationRow({
|
|
|
158
165
|
"size-4 rounded-[4px] transition-opacity",
|
|
159
166
|
selecting || selected
|
|
160
167
|
? "opacity-100"
|
|
161
|
-
:
|
|
168
|
+
: // Unseen on a touch screen, it takes no taps from the row.
|
|
169
|
+
"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 pointer-coarse:pointer-events-none"
|
|
162
170
|
)}
|
|
163
171
|
/>
|
|
164
172
|
{unread && !selecting && !selected && (
|
|
@@ -198,6 +206,11 @@ function ConversationRow({
|
|
|
198
206
|
{conversation.messageCount}
|
|
199
207
|
</span>
|
|
200
208
|
)}
|
|
209
|
+
{conversation.draft && (
|
|
210
|
+
<span className="text-destructive shrink-0 text-[12px] font-medium">
|
|
211
|
+
Draft
|
|
212
|
+
</span>
|
|
213
|
+
)}
|
|
201
214
|
</span>
|
|
202
215
|
|
|
203
216
|
<span className="mail-subject pointer-events-none min-w-0 truncate text-[13px] leading-5 [grid-area:subject]">
|
|
@@ -212,7 +225,9 @@ function ConversationRow({
|
|
|
212
225
|
<span aria-hidden="true" className="mail-dash text-border px-1.5">
|
|
213
226
|
—
|
|
214
227
|
</span>
|
|
215
|
-
{conversation.
|
|
228
|
+
{conversation.searchMatch?.snippet ||
|
|
229
|
+
conversation.preview ||
|
|
230
|
+
"No text preview"}
|
|
216
231
|
</span>
|
|
217
232
|
</span>
|
|
218
233
|
|
|
@@ -248,6 +263,10 @@ function emptyFolderHint(systemType: string | null | undefined) {
|
|
|
248
263
|
return "Deleted conversations wait here until you delete them permanently.";
|
|
249
264
|
}
|
|
250
265
|
|
|
266
|
+
case "drafts": {
|
|
267
|
+
return "Messages you start writing are saved here until you send them.";
|
|
268
|
+
}
|
|
269
|
+
|
|
251
270
|
default: {
|
|
252
271
|
return "New conversations will appear here as soon as they arrive.";
|
|
253
272
|
}
|
|
@@ -277,6 +296,25 @@ export function ConversationList({ mail }: { mail: MailController }) {
|
|
|
277
296
|
|
|
278
297
|
const hasConversations = conversations.length > 0;
|
|
279
298
|
|
|
299
|
+
// What the folder's count says the list holds; a search can't tell.
|
|
300
|
+
const countedRows = debouncedSearch
|
|
301
|
+
? 0
|
|
302
|
+
: unreadOnly
|
|
303
|
+
? unreadInFolder
|
|
304
|
+
: (activeFolder?.totalCount ?? 0);
|
|
305
|
+
|
|
306
|
+
// An empty list being read again while the count says it isn't empty
|
|
307
|
+
// (data from before a change) waits for its rows: "is empty" would be
|
|
308
|
+
// wrong for a moment.
|
|
309
|
+
const awaitingRows =
|
|
310
|
+
!hasConversations && conversationsQuery.isFetching && countedRows > 0;
|
|
311
|
+
|
|
312
|
+
const listWaiting = mail.listLoading || awaitingRows;
|
|
313
|
+
// A list seen before stays while the next loads (see useConversations): the
|
|
314
|
+
// skeleton is only for the first, and only if it is slow.
|
|
315
|
+
const listPlaceholder = useDelayedPending(listWaiting);
|
|
316
|
+
const inDrafts = folder === DRAFTS_FOLDER_ID;
|
|
317
|
+
|
|
280
318
|
// Resting on a row (pointer or keyboard focus) starts loading it, so a
|
|
281
319
|
// click usually finds the conversation already there.
|
|
282
320
|
const intentTimer = useRef<ReturnType<typeof setTimeout> | undefined>(
|
|
@@ -285,6 +323,19 @@ export function ConversationList({ mail }: { mail: MailController }) {
|
|
|
285
323
|
|
|
286
324
|
useEffect(() => () => clearTimeout(intentTimer.current), []);
|
|
287
325
|
|
|
326
|
+
const selectButton = useRef<HTMLButtonElement>(null);
|
|
327
|
+
|
|
328
|
+
// Which list the rows are: a search, a filter or a folder's results
|
|
329
|
+
// replace the list they were typed over as a list of their own, from the
|
|
330
|
+
// top, not by moving its rows about.
|
|
331
|
+
const listKey = `${folder}\0${debouncedSearch}\0${unreadOnly}`;
|
|
332
|
+
|
|
333
|
+
/** Leaves selection mode; focus, in its toolbar, goes back to Select. */
|
|
334
|
+
function exitSelection() {
|
|
335
|
+
restoreFocus(() => selectButton.current);
|
|
336
|
+
selection.exit();
|
|
337
|
+
}
|
|
338
|
+
|
|
288
339
|
function intent(targetId: string, when: "soon" | "now" | null) {
|
|
289
340
|
clearTimeout(intentTimer.current);
|
|
290
341
|
|
|
@@ -313,21 +364,23 @@ export function ConversationList({ mail }: { mail: MailController }) {
|
|
|
313
364
|
|
|
314
365
|
let body: ReactNode;
|
|
315
366
|
|
|
316
|
-
if (
|
|
367
|
+
if (listWaiting || listPlaceholder) {
|
|
317
368
|
body = (
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
<
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
369
|
+
<PlaceholderFrame shown={listPlaceholder}>
|
|
370
|
+
<ul aria-busy="true" aria-label="Loading conversations">
|
|
371
|
+
{Array.from({ length: 12 }, (_, index) => (
|
|
372
|
+
<li key={index} className="mail-row border-b border-(--rule)">
|
|
373
|
+
<span className="[grid-area:check]" />
|
|
374
|
+
<Skeleton className="h-3 w-28 [grid-area:from]" />
|
|
375
|
+
<Skeleton
|
|
376
|
+
className="h-3 [grid-area:subject]"
|
|
377
|
+
style={{ width: `${55 + ((index * 37) % 40)}%` }}
|
|
378
|
+
/>
|
|
379
|
+
<Skeleton className="h-3 w-9 justify-self-end [grid-area:date]" />
|
|
380
|
+
</li>
|
|
381
|
+
))}
|
|
382
|
+
</ul>
|
|
383
|
+
</PlaceholderFrame>
|
|
331
384
|
);
|
|
332
385
|
} else if (mail.listError) {
|
|
333
386
|
body = (
|
|
@@ -354,7 +407,7 @@ export function ConversationList({ mail }: { mail: MailController }) {
|
|
|
354
407
|
selecting={selection.active}
|
|
355
408
|
disabled={selection.pending}
|
|
356
409
|
onOpen={() => mail.openConversation(item.conversationId)}
|
|
357
|
-
onToggle={() => selection.toggle(item
|
|
410
|
+
onToggle={() => selection.toggle(item)}
|
|
358
411
|
onIntent={(when) => intent(item.conversationId, when)}
|
|
359
412
|
/>
|
|
360
413
|
))}
|
|
@@ -394,7 +447,7 @@ export function ConversationList({ mail }: { mail: MailController }) {
|
|
|
394
447
|
className="flex min-h-0 flex-1 flex-col"
|
|
395
448
|
onKeyDown={(event) => {
|
|
396
449
|
if (selection.active && !selection.pending && event.key === "Escape") {
|
|
397
|
-
|
|
450
|
+
exitSelection();
|
|
398
451
|
}
|
|
399
452
|
}}
|
|
400
453
|
>
|
|
@@ -407,144 +460,226 @@ export function ConversationList({ mail }: { mail: MailController }) {
|
|
|
407
460
|
</h1>
|
|
408
461
|
</div>
|
|
409
462
|
<div className="flex h-12 items-center justify-between gap-3">
|
|
410
|
-
{selection.active && mailbox
|
|
463
|
+
{selection.active && mailbox && (
|
|
411
464
|
<TooltipProvider delay={300}>
|
|
412
|
-
|
|
465
|
+
{/* Phones fix the toolbar to the bottom; the row keeps its count and filter. */}
|
|
466
|
+
<div className="-ml-1.5 min-w-0 flex-1 max-lg:contents [&_[data-slot=button]]:shrink-0 lg:[&>div:first-child]:h-8 lg:[&>div:first-child]:border-0 lg:[&>div:first-child]:bg-transparent lg:[&>div:first-child]:px-0">
|
|
413
467
|
<ConversationSelectionToolbar
|
|
468
|
+
onDiscardDrafts={
|
|
469
|
+
folder === DRAFTS_FOLDER_ID
|
|
470
|
+
? selection.discardDrafts
|
|
471
|
+
: undefined
|
|
472
|
+
}
|
|
414
473
|
sharedMailboxName={
|
|
415
474
|
mailbox.kind === "shared" ? mailbox.displayName : undefined
|
|
416
475
|
}
|
|
417
476
|
canDeletePermanently={mailbox.canSend}
|
|
418
477
|
folder={folder}
|
|
419
478
|
folders={folders ?? []}
|
|
420
|
-
|
|
479
|
+
selected={selection.selectedConversations}
|
|
421
480
|
allLoadedSelected={selection.allLoadedSelected}
|
|
422
|
-
|
|
423
|
-
selection.selectedConversations.length > 0
|
|
424
|
-
}
|
|
425
|
-
anySelectedUnread={selection.anySelectedUnread}
|
|
426
|
-
hasSelectedIncoming={selection.hasSelectedIncoming}
|
|
427
|
-
allSelectedHaveIncoming={selection.allSelectedHaveIncoming}
|
|
428
|
-
busy={selection.pending}
|
|
481
|
+
busy={selection.pending || mail.listStale}
|
|
429
482
|
onToggleAll={selection.toggleAllLoaded}
|
|
430
483
|
onAction={selection.run}
|
|
431
484
|
onReport={selection.report}
|
|
432
|
-
|
|
485
|
+
onNotSpam={selection.notSpam}
|
|
486
|
+
onExit={exitSelection}
|
|
433
487
|
/>
|
|
434
488
|
</div>
|
|
435
489
|
</TooltipProvider>
|
|
436
|
-
)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
{
|
|
490
|
+
)}
|
|
491
|
+
<div
|
|
492
|
+
className={cn(
|
|
493
|
+
"contents",
|
|
494
|
+
selection.active && mailbox && "lg:hidden"
|
|
495
|
+
)}
|
|
496
|
+
>
|
|
497
|
+
<div className="flex min-w-0 items-baseline gap-2">
|
|
498
|
+
<h1 className="shrink-0 text-[15px] leading-6 font-semibold tracking-[-0.012em] max-lg:hidden">
|
|
499
|
+
{folderName}
|
|
500
|
+
</h1>
|
|
501
|
+
<p className="text-muted-foreground min-w-0 truncate text-xs tabular-nums">
|
|
502
|
+
{listPlaceholder ? (
|
|
503
|
+
"Loading…"
|
|
504
|
+
) : mail.listLoading ? null : (
|
|
505
|
+
<>
|
|
506
|
+
{/* A narrow header keeps the unread count and drops the total. */}
|
|
507
|
+
<span
|
|
508
|
+
className={
|
|
509
|
+
unreadInFolder > 0
|
|
510
|
+
? "hidden @[24rem]/list-head:inline"
|
|
511
|
+
: undefined
|
|
512
|
+
}
|
|
513
|
+
>
|
|
514
|
+
{displayedConversationCount}
|
|
515
|
+
{/* Phones have room for the word: the folder name sits above the row. */}
|
|
516
|
+
<span className="hidden max-lg:inline @[26rem]/list-head:inline">
|
|
517
|
+
{" "}
|
|
518
|
+
{displayedConversationCount === "1"
|
|
519
|
+
? "conversation"
|
|
520
|
+
: "conversations"}
|
|
464
521
|
</span>
|
|
465
|
-
{unreadInFolder > 0 &&
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
522
|
+
{unreadInFolder > 0 && " · "}
|
|
523
|
+
</span>
|
|
524
|
+
{unreadInFolder > 0 && (
|
|
525
|
+
<span className="text-primary font-medium">
|
|
526
|
+
{unreadInFolder} unread
|
|
527
|
+
</span>
|
|
528
|
+
)}
|
|
529
|
+
{debouncedSearch && <> · matching “{debouncedSearch}”</>}
|
|
530
|
+
</>
|
|
531
|
+
)}
|
|
532
|
+
</p>
|
|
533
|
+
</div>
|
|
534
|
+
<div className="flex shrink-0 items-center gap-1.5">
|
|
535
|
+
{!inDrafts && (
|
|
476
536
|
<SegmentedFilter
|
|
477
537
|
unreadOnly={unreadOnly}
|
|
478
538
|
onToggle={mail.toggleUnreadOnly}
|
|
479
539
|
/>
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
variant="ghost"
|
|
483
|
-
size="icon-sm"
|
|
484
|
-
className="size-7"
|
|
485
|
-
aria-label="Refresh"
|
|
486
|
-
disabled={conversationsQuery.isFetching}
|
|
487
|
-
onClick={() => void conversationsQuery.refetch()}
|
|
488
|
-
>
|
|
489
|
-
<RotateCw
|
|
490
|
-
className={cn(
|
|
491
|
-
conversationsQuery.isRefetching &&
|
|
492
|
-
!conversationsQuery.isFetchingNextPage &&
|
|
493
|
-
"animate-spin"
|
|
494
|
-
)}
|
|
495
|
-
/>
|
|
496
|
-
</Button>
|
|
497
|
-
</ToolbarTooltip>
|
|
540
|
+
)}
|
|
541
|
+
<ToolbarTooltip label={mail.refreshError ?? "Refresh"}>
|
|
498
542
|
<Button
|
|
499
543
|
variant="ghost"
|
|
500
|
-
size="sm"
|
|
501
|
-
className=
|
|
502
|
-
|
|
503
|
-
|
|
544
|
+
size={mail.refreshError ? "sm" : "icon-sm"}
|
|
545
|
+
className={
|
|
546
|
+
mail.refreshError ? "text-destructive h-7" : "size-7"
|
|
547
|
+
}
|
|
548
|
+
aria-label={mail.refreshError ? "Retry refresh" : "Refresh"}
|
|
549
|
+
disabled={conversationsQuery.isFetching}
|
|
550
|
+
onClick={mail.retryList}
|
|
504
551
|
>
|
|
505
|
-
<
|
|
552
|
+
<RotateCw
|
|
553
|
+
className={cn(
|
|
554
|
+
conversationsQuery.isRefetching &&
|
|
555
|
+
!conversationsQuery.isFetchingNextPage &&
|
|
556
|
+
// Another list loading is not this one refreshing.
|
|
557
|
+
!conversationsQuery.isPlaceholderData &&
|
|
558
|
+
"animate-spin"
|
|
559
|
+
)}
|
|
560
|
+
/>
|
|
561
|
+
{mail.refreshError && "Retry"}
|
|
506
562
|
</Button>
|
|
507
|
-
</
|
|
508
|
-
|
|
509
|
-
|
|
563
|
+
</ToolbarTooltip>
|
|
564
|
+
<Button
|
|
565
|
+
ref={selectButton}
|
|
566
|
+
variant="ghost"
|
|
567
|
+
size="sm"
|
|
568
|
+
className="aria-pressed:bg-accent h-7 px-2 text-xs"
|
|
569
|
+
aria-pressed={selection.active}
|
|
570
|
+
disabled={
|
|
571
|
+
selection.pending ||
|
|
572
|
+
mail.listStale ||
|
|
573
|
+
(!hasConversations && !selection.active)
|
|
574
|
+
}
|
|
575
|
+
onClick={selection.active ? exitSelection : selection.start}
|
|
576
|
+
>
|
|
577
|
+
<ListChecks /> Select
|
|
578
|
+
</Button>
|
|
579
|
+
</div>
|
|
580
|
+
</div>
|
|
510
581
|
</div>
|
|
511
582
|
<SearchField mail={mail} className="mb-2.5 h-9 md:hidden" />
|
|
512
583
|
</div>
|
|
513
584
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
selection.selectedConversations.length > 0
|
|
528
|
-
}
|
|
529
|
-
disabled={selection.pending}
|
|
530
|
-
onCheckedChange={selection.toggleAllLoaded}
|
|
531
|
-
className="size-4 rounded-[4px]"
|
|
532
|
-
/>
|
|
533
|
-
</span>
|
|
534
|
-
<span data-col="from-wide" className="[grid-area:from]">
|
|
535
|
-
From
|
|
536
|
-
</span>
|
|
537
|
-
<span data-col="from-narrow" className="[grid-area:from]">
|
|
538
|
-
From · Subject
|
|
539
|
-
</span>
|
|
540
|
-
<span data-col="subject" className="[grid-area:subject]">
|
|
541
|
-
Subject
|
|
542
|
-
</span>
|
|
543
|
-
<span className="text-right [grid-area:date]">Received</span>
|
|
544
|
-
</div>
|
|
585
|
+
{mailbox &&
|
|
586
|
+
(activeFolder?.systemType === "trash" ||
|
|
587
|
+
activeFolder?.systemType === "spam") &&
|
|
588
|
+
activeFolder.totalCount > 0 && (
|
|
589
|
+
<FolderCleanupBar
|
|
590
|
+
mailboxId={mailbox.id}
|
|
591
|
+
folder={activeFolder.systemType}
|
|
592
|
+
folderName={folderName}
|
|
593
|
+
conversationCount={activeFolder.totalCount}
|
|
594
|
+
retentionDays={activeFolder.retentionDays}
|
|
595
|
+
canEmpty={mailbox.canSend}
|
|
596
|
+
follow={mail.followChange}
|
|
597
|
+
/>
|
|
545
598
|
)}
|
|
546
|
-
|
|
547
|
-
|
|
599
|
+
|
|
600
|
+
<ListScroller key={listKey} hidden={Boolean(conversationId)}>
|
|
601
|
+
<StaleContent stale={mail.listStale}>
|
|
602
|
+
{hasConversations &&
|
|
603
|
+
!mail.listLoading &&
|
|
604
|
+
!listPlaceholder &&
|
|
605
|
+
!mail.listError && (
|
|
606
|
+
<div className="mail-columns border-border bg-surface-sunken text-muted-foreground sticky top-0 z-20 h-8 border-b text-[11px] font-semibold tracking-[0.04em] uppercase">
|
|
607
|
+
<span className="grid place-items-center [grid-area:check]">
|
|
608
|
+
<Checkbox
|
|
609
|
+
aria-label={
|
|
610
|
+
selection.allLoadedSelected
|
|
611
|
+
? "Deselect all loaded conversations"
|
|
612
|
+
: "Select all loaded conversations"
|
|
613
|
+
}
|
|
614
|
+
checked={selection.allLoadedSelected}
|
|
615
|
+
indeterminate={
|
|
616
|
+
!selection.allLoadedSelected &&
|
|
617
|
+
selection.selectedConversations.length > 0
|
|
618
|
+
}
|
|
619
|
+
disabled={selection.pending}
|
|
620
|
+
onCheckedChange={selection.toggleAllLoaded}
|
|
621
|
+
className="size-4 rounded-[4px]"
|
|
622
|
+
/>
|
|
623
|
+
</span>
|
|
624
|
+
<span data-col="from-wide" className="[grid-area:from]">
|
|
625
|
+
{inDrafts ? "To" : "From"}
|
|
626
|
+
</span>
|
|
627
|
+
<span data-col="from-narrow" className="[grid-area:from]">
|
|
628
|
+
{inDrafts ? "To" : "From"} · Subject
|
|
629
|
+
</span>
|
|
630
|
+
<span data-col="subject" className="[grid-area:subject]">
|
|
631
|
+
Subject
|
|
632
|
+
</span>
|
|
633
|
+
<span className="text-right [grid-area:date]">
|
|
634
|
+
{inDrafts ? "Saved" : "Received"}
|
|
635
|
+
</span>
|
|
636
|
+
</div>
|
|
637
|
+
)}
|
|
638
|
+
{body}
|
|
639
|
+
</StaleContent>
|
|
640
|
+
</ListScroller>
|
|
641
|
+
</div>
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* The list's scroll box, keyed by the list it shows. A phone hides it behind
|
|
647
|
+
* the open conversation, and a hidden box may lose its scroll (Safari): shown
|
|
648
|
+
* again, it goes back exactly where it was.
|
|
649
|
+
*/
|
|
650
|
+
function ListScroller({
|
|
651
|
+
hidden,
|
|
652
|
+
children,
|
|
653
|
+
}: {
|
|
654
|
+
hidden: boolean;
|
|
655
|
+
children: ReactNode;
|
|
656
|
+
}) {
|
|
657
|
+
const scroller = useRef<HTMLDivElement>(null);
|
|
658
|
+
const lastScroll = useRef(0);
|
|
659
|
+
const wasHidden = useRef(hidden);
|
|
660
|
+
|
|
661
|
+
useLayoutEffect(() => {
|
|
662
|
+
const element = scroller.current;
|
|
663
|
+
|
|
664
|
+
if (wasHidden.current && !hidden && element && element.clientHeight > 0) {
|
|
665
|
+
element.scrollTop = lastScroll.current;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
wasHidden.current = hidden;
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
return (
|
|
672
|
+
<div
|
|
673
|
+
ref={scroller}
|
|
674
|
+
onScroll={(event) => {
|
|
675
|
+
// Only while it shows: hiding it can reset its scroll.
|
|
676
|
+
if (event.currentTarget.clientHeight > 0) {
|
|
677
|
+
lastScroll.current = event.currentTarget.scrollTop;
|
|
678
|
+
}
|
|
679
|
+
}}
|
|
680
|
+
className="@container/mail-list min-h-0 flex-1 overflow-y-auto pb-24"
|
|
681
|
+
>
|
|
682
|
+
{children}
|
|
548
683
|
</div>
|
|
549
684
|
);
|
|
550
685
|
}
|