@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
|
@@ -2,7 +2,7 @@ import { TooltipProvider, cn } from "@open-workspace/core/ui";
|
|
|
2
2
|
|
|
3
3
|
import { FolderGlyph } from "./folder-glyph";
|
|
4
4
|
import { FolderManager } from "./folder-manager";
|
|
5
|
-
import { orderedFolders, unreadOf } from "./mail-folders";
|
|
5
|
+
import { folderCountLabel, orderedFolders, unreadOf } from "./mail-folders";
|
|
6
6
|
import { ComposeButton, MailboxGlyph } from "./mail-nav";
|
|
7
7
|
import { ToolbarTooltip } from "./toolbar-tooltip";
|
|
8
8
|
import type { MailController } from "./use-mail-controller";
|
|
@@ -59,7 +59,8 @@ export function NavRail({ mail }: { mail: MailController }) {
|
|
|
59
59
|
type="button"
|
|
60
60
|
aria-current={active ? "true" : undefined}
|
|
61
61
|
aria-label={`${item.displayName}${item.unreadCount && !active ? `, ${item.unreadCount} unread` : ""}`}
|
|
62
|
-
|
|
62
|
+
{...(active ? {} : mail.listIntent(item.id))}
|
|
63
|
+
onClick={() => void mail.switchMailbox(item.id)}
|
|
63
64
|
className={cn(
|
|
64
65
|
railItemClass,
|
|
65
66
|
active ? "bg-sidebar-accent" : "hover:bg-foreground/[0.045]"
|
|
@@ -88,12 +89,13 @@ export function NavRail({ mail }: { mail: MailController }) {
|
|
|
88
89
|
<ToolbarTooltip
|
|
89
90
|
key={entry.id}
|
|
90
91
|
side="right"
|
|
91
|
-
label={`${entry.name}${unread ? ` · ${unread}
|
|
92
|
+
label={`${entry.name}${unread ? ` · ${folderCountLabel(entry, unread)}` : ""}`}
|
|
92
93
|
>
|
|
93
94
|
<button
|
|
94
95
|
type="button"
|
|
95
96
|
aria-current={active ? "page" : undefined}
|
|
96
|
-
aria-label={`${entry.name}${unread ? `, ${unread}
|
|
97
|
+
aria-label={`${entry.name}${unread ? `, ${folderCountLabel(entry, unread)}` : ""}`}
|
|
98
|
+
{...mail.listIntent(mail.mailbox?.id, entry.id)}
|
|
97
99
|
onClick={() => mail.selectFolder(entry.id)}
|
|
98
100
|
className={cn(
|
|
99
101
|
railItemClass,
|
|
@@ -116,6 +118,7 @@ export function NavRail({ mail }: { mail: MailController }) {
|
|
|
116
118
|
<span className="mt-0.5 [&_button]:size-10 [&_button]:rounded-[10px]">
|
|
117
119
|
<FolderManager
|
|
118
120
|
mailboxId={mail.mailbox.id}
|
|
121
|
+
canOrganize={mail.mailbox.canOrganize}
|
|
119
122
|
activeFolderId={folder}
|
|
120
123
|
folders={folders ?? []}
|
|
121
124
|
onSelectFolder={mail.selectFolder}
|
package/src/mail/mail-nav.tsx
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DelayedFallback,
|
|
3
|
+
Skeleton,
|
|
4
|
+
TooltipProvider,
|
|
5
|
+
cn,
|
|
6
|
+
} from "@open-workspace/core/ui";
|
|
2
7
|
import { ChevronRight, PenLine } from "lucide-react";
|
|
3
8
|
import { useEffect, useState } from "react";
|
|
4
9
|
import { z } from "zod";
|
|
5
10
|
|
|
6
11
|
import { FolderGlyph } from "./folder-glyph";
|
|
7
12
|
import { FolderManager } from "./folder-manager";
|
|
8
|
-
import { orderedFolders, unreadOf } from "./mail-folders";
|
|
13
|
+
import { folderCountLabel, orderedFolders, unreadOf } from "./mail-folders";
|
|
9
14
|
import { CountPill, Monogram } from "./mail-primitives";
|
|
10
15
|
import type { Mailbox, MailFolder } from "./types";
|
|
11
16
|
import type { MailController } from "./use-mail-controller";
|
|
@@ -46,6 +51,7 @@ export function ComposeButton({
|
|
|
46
51
|
<button
|
|
47
52
|
type="button"
|
|
48
53
|
aria-label={iconOnly ? "New message" : undefined}
|
|
54
|
+
data-compose-opener
|
|
49
55
|
disabled={disabled}
|
|
50
56
|
onClick={onClick}
|
|
51
57
|
className={cn(
|
|
@@ -66,10 +72,13 @@ function FolderRow({
|
|
|
66
72
|
folder,
|
|
67
73
|
active,
|
|
68
74
|
onSelect,
|
|
75
|
+
intent,
|
|
69
76
|
}: {
|
|
70
77
|
folder: MailFolder;
|
|
71
78
|
active: boolean;
|
|
72
79
|
onSelect: () => void;
|
|
80
|
+
/** Starts loading the folder's list when the person is about to open it. */
|
|
81
|
+
intent: ReturnType<MailController["listIntent"]>;
|
|
73
82
|
}) {
|
|
74
83
|
const unread = unreadOf(folder);
|
|
75
84
|
|
|
@@ -78,6 +87,7 @@ function FolderRow({
|
|
|
78
87
|
<button
|
|
79
88
|
type="button"
|
|
80
89
|
aria-current={active ? "page" : undefined}
|
|
90
|
+
{...intent}
|
|
81
91
|
onClick={onSelect}
|
|
82
92
|
className={cn(
|
|
83
93
|
"relative flex h-7.5 w-full items-center gap-2.5 rounded-md pr-1 pl-2.5 text-left text-[13px] transition-colors outline-none",
|
|
@@ -100,7 +110,7 @@ function FolderRow({
|
|
|
100
110
|
<CountPill
|
|
101
111
|
count={unread}
|
|
102
112
|
strong={active || folder.systemType === "inbox"}
|
|
103
|
-
label={
|
|
113
|
+
label={folderCountLabel(folder, unread)}
|
|
104
114
|
/>
|
|
105
115
|
</button>
|
|
106
116
|
</li>
|
|
@@ -112,7 +122,7 @@ const EXPANDED_KEY = "openworkspace.mail.expandedMailboxes";
|
|
|
112
122
|
/** What `writeExpanded` stores: the ids of the expanded mailboxes. */
|
|
113
123
|
const expandedIds = z.array(z.string());
|
|
114
124
|
|
|
115
|
-
function readExpanded()
|
|
125
|
+
function readExpanded() {
|
|
116
126
|
try {
|
|
117
127
|
const stored = expandedIds.safeParse(
|
|
118
128
|
JSON.parse(localStorage.getItem(EXPANDED_KEY) ?? "[]")
|
|
@@ -188,13 +198,16 @@ export function NavTree({ mail }: { mail: MailController }) {
|
|
|
188
198
|
<p className="text-muted-foreground px-2 pt-3 pb-1.5 text-[11px] font-semibold tracking-[0.06em] uppercase">
|
|
189
199
|
Mailboxes
|
|
190
200
|
</p>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
<DelayedFallback
|
|
202
|
+
pending={mail.mailboxQuery.isLoading}
|
|
203
|
+
fallback={
|
|
204
|
+
<div className="space-y-2 px-2 pt-1">
|
|
205
|
+
{Array.from({ length: 6 }, (_, index) => (
|
|
206
|
+
<Skeleton key={index} className="h-5 w-full" />
|
|
207
|
+
))}
|
|
208
|
+
</div>
|
|
209
|
+
}
|
|
210
|
+
>
|
|
198
211
|
<ul className="space-y-0.5">
|
|
199
212
|
{mail.mailboxes.map((item) => {
|
|
200
213
|
const active = item.id === activeMailbox?.id;
|
|
@@ -222,10 +235,11 @@ export function NavTree({ mail }: { mail: MailController }) {
|
|
|
222
235
|
type="button"
|
|
223
236
|
title={item.address}
|
|
224
237
|
aria-current={active ? "true" : undefined}
|
|
238
|
+
{...(active ? {} : mail.listIntent(item.id))}
|
|
225
239
|
onClick={() => {
|
|
226
240
|
tree.open(item.id);
|
|
227
241
|
|
|
228
|
-
if (!active) mail.
|
|
242
|
+
if (!active) void mail.switchMailbox(item.id);
|
|
229
243
|
}}
|
|
230
244
|
className="focus-visible:ring-sidebar-ring flex h-full min-w-0 flex-1 items-center gap-1.5 rounded-md text-left outline-none focus-visible:ring-2"
|
|
231
245
|
>
|
|
@@ -253,6 +267,7 @@ export function NavTree({ mail }: { mail: MailController }) {
|
|
|
253
267
|
<MailboxFolders
|
|
254
268
|
mailbox={item}
|
|
255
269
|
activeFolder={active ? mail.folder : null}
|
|
270
|
+
intent={(folder) => mail.listIntent(item.id, folder)}
|
|
256
271
|
onSelect={(folder) => {
|
|
257
272
|
mail.openFolder(item.id, folder);
|
|
258
273
|
}}
|
|
@@ -262,7 +277,7 @@ export function NavTree({ mail }: { mail: MailController }) {
|
|
|
262
277
|
);
|
|
263
278
|
})}
|
|
264
279
|
</ul>
|
|
265
|
-
|
|
280
|
+
</DelayedFallback>
|
|
266
281
|
</div>
|
|
267
282
|
</nav>
|
|
268
283
|
</TooltipProvider>
|
|
@@ -274,51 +289,56 @@ function MailboxFolders({
|
|
|
274
289
|
mailbox,
|
|
275
290
|
activeFolder,
|
|
276
291
|
onSelect,
|
|
292
|
+
intent,
|
|
277
293
|
}: {
|
|
278
294
|
mailbox: Mailbox;
|
|
279
295
|
/** The selected folder when this is the active mailbox. */
|
|
280
296
|
activeFolder: string | null;
|
|
281
297
|
onSelect: (folder: string) => void;
|
|
298
|
+
intent: (folder: string) => ReturnType<MailController["listIntent"]>;
|
|
282
299
|
}) {
|
|
283
300
|
const foldersQuery = useFolders(mailbox.id);
|
|
284
301
|
const folders = foldersQuery.data?.folders ?? [];
|
|
285
302
|
|
|
286
303
|
return (
|
|
287
304
|
<div className="border-sidebar-border relative mt-0.5 mb-2 ml-[13px] border-l pl-2">
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
) : (
|
|
295
|
-
<>
|
|
296
|
-
{/* The mailbox's address heads its one list of folders, with their settings beside it. */}
|
|
297
|
-
<div className="flex h-7 items-center gap-1 pl-2.5">
|
|
298
|
-
<p className="text-muted-foreground min-w-0 flex-1 truncate text-[11px]">
|
|
299
|
-
{mailbox.address}
|
|
300
|
-
</p>
|
|
301
|
-
<span className="[&_button]:size-6 [&_button]:rounded-md [&_svg]:size-3.5">
|
|
302
|
-
<FolderManager
|
|
303
|
-
mailboxId={mailbox.id}
|
|
304
|
-
activeFolderId={activeFolder ?? "inbox"}
|
|
305
|
-
folders={folders}
|
|
306
|
-
onSelectFolder={onSelect}
|
|
307
|
-
/>
|
|
308
|
-
</span>
|
|
309
|
-
</div>
|
|
310
|
-
<ul className="space-y-px">
|
|
311
|
-
{orderedFolders(folders).map((entry) => (
|
|
312
|
-
<FolderRow
|
|
313
|
-
key={entry.id}
|
|
314
|
-
folder={entry}
|
|
315
|
-
active={entry.id === activeFolder}
|
|
316
|
-
onSelect={() => onSelect(entry.id)}
|
|
317
|
-
/>
|
|
305
|
+
<DelayedFallback
|
|
306
|
+
pending={foldersQuery.isLoading}
|
|
307
|
+
fallback={
|
|
308
|
+
<div className="space-y-2 py-1.5 pl-2">
|
|
309
|
+
{Array.from({ length: 5 }, (_, index) => (
|
|
310
|
+
<Skeleton key={index} className="h-4 w-4/5" />
|
|
318
311
|
))}
|
|
319
|
-
</
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
</div>
|
|
313
|
+
}
|
|
314
|
+
>
|
|
315
|
+
{/* The mailbox's address heads its one list of folders, with their settings beside it. */}
|
|
316
|
+
<div className="flex h-7 items-center gap-1 pl-2.5">
|
|
317
|
+
<p className="text-muted-foreground min-w-0 flex-1 truncate text-[11px]">
|
|
318
|
+
{mailbox.address}
|
|
319
|
+
</p>
|
|
320
|
+
<span className="[&_button]:size-6 [&_button]:rounded-md [&_svg]:size-3.5">
|
|
321
|
+
<FolderManager
|
|
322
|
+
mailboxId={mailbox.id}
|
|
323
|
+
canOrganize={mailbox.canOrganize}
|
|
324
|
+
activeFolderId={activeFolder ?? "inbox"}
|
|
325
|
+
folders={folders}
|
|
326
|
+
onSelectFolder={onSelect}
|
|
327
|
+
/>
|
|
328
|
+
</span>
|
|
329
|
+
</div>
|
|
330
|
+
<ul className="space-y-px">
|
|
331
|
+
{orderedFolders(folders).map((entry) => (
|
|
332
|
+
<FolderRow
|
|
333
|
+
key={entry.id}
|
|
334
|
+
folder={entry}
|
|
335
|
+
active={entry.id === activeFolder}
|
|
336
|
+
onSelect={() => onSelect(entry.id)}
|
|
337
|
+
intent={intent(entry.id)}
|
|
338
|
+
/>
|
|
339
|
+
))}
|
|
340
|
+
</ul>
|
|
341
|
+
</DelayedFallback>
|
|
322
342
|
</div>
|
|
323
343
|
);
|
|
324
344
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { QueryClient } from "@tanstack/react-query";
|
|
2
2
|
|
|
3
3
|
import { parseMailPath } from "../../shared/mail-path";
|
|
4
|
+
import { autoReplyQuery } from "../settings/settings-queries";
|
|
4
5
|
import {
|
|
5
6
|
conversationQuery,
|
|
6
7
|
conversationsQuery,
|
|
@@ -27,32 +28,52 @@ export function prefetchMail({
|
|
|
27
28
|
if (pathname !== "/" && !route) return;
|
|
28
29
|
const folder = route?.folder ?? "inbox";
|
|
29
30
|
|
|
31
|
+
const params = new URLSearchParams(
|
|
32
|
+
pathname === window.location.pathname ? window.location.search : ""
|
|
33
|
+
);
|
|
34
|
+
|
|
30
35
|
const start = (mailboxId: string, conversationId: string | null) => {
|
|
31
36
|
void queryClient.prefetchQuery(foldersQuery(mailboxId));
|
|
32
37
|
void queryClient.prefetchInfiniteQuery(
|
|
33
|
-
conversationsQuery(
|
|
38
|
+
conversationsQuery(
|
|
39
|
+
mailboxId,
|
|
40
|
+
folder,
|
|
41
|
+
params.get("q")?.trim() ?? "",
|
|
42
|
+
false
|
|
43
|
+
)
|
|
34
44
|
);
|
|
35
45
|
|
|
36
46
|
if (conversationId) {
|
|
37
47
|
void queryClient.prefetchInfiniteQuery(
|
|
38
|
-
conversationQuery(
|
|
48
|
+
conversationQuery(
|
|
49
|
+
mailboxId,
|
|
50
|
+
conversationId,
|
|
51
|
+
params.get("match") ?? undefined
|
|
52
|
+
)
|
|
39
53
|
);
|
|
40
54
|
}
|
|
41
55
|
};
|
|
42
56
|
|
|
43
57
|
const mailboxes = queryClient.fetchQuery(mailboxesQuery());
|
|
44
58
|
|
|
45
|
-
if (route)
|
|
46
|
-
start(route.mailboxId, route.conversationId);
|
|
47
|
-
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
59
|
+
if (route) start(route.mailboxId, route.conversationId);
|
|
50
60
|
|
|
51
61
|
void mailboxes.then(
|
|
52
62
|
(data) => {
|
|
53
|
-
const
|
|
63
|
+
const mailbox = route
|
|
64
|
+
? data.mailboxes.find((box) => box.id === route.mailboxId)
|
|
65
|
+
: data.mailboxes[0];
|
|
66
|
+
|
|
67
|
+
if (!mailbox) return;
|
|
68
|
+
|
|
69
|
+
if (!route) start(mailbox.id, null);
|
|
54
70
|
|
|
55
|
-
if (
|
|
71
|
+
if (mailbox.kind === "personal") {
|
|
72
|
+
void queryClient.prefetchQuery({
|
|
73
|
+
...autoReplyQuery(mailbox.id),
|
|
74
|
+
staleTime: 60_000,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
56
77
|
},
|
|
57
78
|
() => undefined
|
|
58
79
|
);
|
|
@@ -11,10 +11,12 @@ function hueFor(value: string) {
|
|
|
11
11
|
return Math.abs(hash) % 360;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function monogramStyle(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function monogramStyle(name: string) {
|
|
15
|
+
const style: CSSProperties & Record<"--monogram-hue", number> = {
|
|
16
|
+
"--monogram-hue": hueFor(name),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return style;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export function Monogram({
|
package/src/mail/mail-queries.ts
CHANGED
|
@@ -6,11 +6,9 @@ import {
|
|
|
6
6
|
} from "@tanstack/react-query";
|
|
7
7
|
import type { QueryClient } from "@tanstack/react-query";
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
CONVERSATION_PAGE_SIZE,
|
|
11
|
-
MAX_BULK_CONVERSATION_COUNT,
|
|
12
|
-
} from "../../shared/mail";
|
|
9
|
+
import { CONVERSATION_PAGE_SIZE } from "../../shared/mail";
|
|
13
10
|
import { mailApi } from "../lib/mail-api";
|
|
11
|
+
import { folderAfterMailboxSwitch } from "./mail-folders";
|
|
14
12
|
import type { MessageDetail } from "./types";
|
|
15
13
|
|
|
16
14
|
/**
|
|
@@ -19,7 +17,7 @@ import type { MessageDetail } from "./types";
|
|
|
19
17
|
* Kept free of UI imports so the app's entry stays small.
|
|
20
18
|
*/
|
|
21
19
|
|
|
22
|
-
const MESSAGE_PAGE_SIZE = 25;
|
|
20
|
+
export const MESSAGE_PAGE_SIZE = 25;
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* Realtime updates (with versions) say when mail data changed, so cached
|
|
@@ -92,20 +90,35 @@ export function conversationsQuery(
|
|
|
92
90
|
)
|
|
93
91
|
)
|
|
94
92
|
: skipToken,
|
|
95
|
-
getNextPageParam: (page
|
|
96
|
-
const loadedCount = pages.reduce(
|
|
97
|
-
(count, loadedPage) => count + loadedPage.conversations.length,
|
|
98
|
-
0
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
return loadedCount < MAX_BULK_CONVERSATION_COUNT
|
|
102
|
-
? (page.nextCursor ?? undefined)
|
|
103
|
-
: undefined;
|
|
104
|
-
},
|
|
93
|
+
getNextPageParam: (page) => page.nextCursor ?? undefined,
|
|
105
94
|
retry: retryServerErrors,
|
|
106
95
|
});
|
|
107
96
|
}
|
|
108
97
|
|
|
98
|
+
/** A mailbox switch opens a fresh list with its search and unread filter cleared. */
|
|
99
|
+
export async function prefetchMailboxSwitch(
|
|
100
|
+
client: QueryClient,
|
|
101
|
+
mailboxId: string,
|
|
102
|
+
currentFolder: string,
|
|
103
|
+
selectedFolder?: string
|
|
104
|
+
) {
|
|
105
|
+
const target =
|
|
106
|
+
selectedFolder ??
|
|
107
|
+
folderAfterMailboxSwitch(
|
|
108
|
+
currentFolder,
|
|
109
|
+
(
|
|
110
|
+
await client.fetchQuery({
|
|
111
|
+
...foldersQuery(mailboxId),
|
|
112
|
+
staleTime: 30_000,
|
|
113
|
+
})
|
|
114
|
+
).folders
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
await client.prefetchInfiniteQuery(
|
|
118
|
+
conversationsQuery(mailboxId, target, "", false)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
109
122
|
let sanitizer: Promise<typeof import("./sanitize-email-html")> | undefined;
|
|
110
123
|
|
|
111
124
|
/**
|
|
@@ -156,11 +169,14 @@ function sanitizeAhead(
|
|
|
156
169
|
client: QueryClient,
|
|
157
170
|
mailboxId: string,
|
|
158
171
|
messages: MessageDetail[],
|
|
159
|
-
firstPage: boolean
|
|
172
|
+
firstPage: boolean,
|
|
173
|
+
matchId?: string
|
|
160
174
|
) {
|
|
161
175
|
messages.forEach((message, index) => {
|
|
162
176
|
const expanded =
|
|
163
|
-
|
|
177
|
+
message.id === matchId ||
|
|
178
|
+
!message.isRead ||
|
|
179
|
+
(firstPage && index === messages.length - 1);
|
|
164
180
|
|
|
165
181
|
if (expanded && message.bodyHtml) {
|
|
166
182
|
void client.prefetchQuery(sanitizedHtmlQuery(mailboxId, message));
|
|
@@ -170,7 +186,8 @@ function sanitizeAhead(
|
|
|
170
186
|
|
|
171
187
|
export function conversationQuery(
|
|
172
188
|
mailboxId: string | undefined,
|
|
173
|
-
conversationId: string | undefined
|
|
189
|
+
conversationId: string | undefined,
|
|
190
|
+
matchId?: string
|
|
174
191
|
) {
|
|
175
192
|
return infiniteQueryOptions({
|
|
176
193
|
queryKey: ["conversation", mailboxId, conversationId],
|
|
@@ -185,6 +202,7 @@ export function conversationQuery(
|
|
|
185
202
|
query: {
|
|
186
203
|
mailboxId,
|
|
187
204
|
limit: String(MESSAGE_PAGE_SIZE),
|
|
205
|
+
match: pageParam ? undefined : matchId,
|
|
188
206
|
cursor: pageParam,
|
|
189
207
|
},
|
|
190
208
|
},
|
|
@@ -196,14 +214,98 @@ export function conversationQuery(
|
|
|
196
214
|
client,
|
|
197
215
|
mailboxId,
|
|
198
216
|
page.messages,
|
|
199
|
-
pageParam === undefined
|
|
217
|
+
pageParam === undefined,
|
|
218
|
+
matchId
|
|
200
219
|
);
|
|
201
220
|
|
|
202
221
|
return page;
|
|
203
222
|
}
|
|
204
223
|
: skipToken,
|
|
205
224
|
getNextPageParam: (page) => page.nextCursor ?? undefined,
|
|
206
|
-
|
|
225
|
+
// Autosaves in another window do not broadcast mailbox changes. Recheck
|
|
226
|
+
// a saved reply on return, reusing a just-completed hover prefetch.
|
|
227
|
+
staleTime: (query) =>
|
|
228
|
+
query.state.data?.pages[0]?.replyDraft ? 1000 : CONVERSATION_STALE_MS,
|
|
207
229
|
retry: retryServerErrors,
|
|
208
230
|
});
|
|
209
231
|
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Loads a conversation the person is about to open, with the sanitized
|
|
235
|
+
* bodies it opens with. A fetch sanitizes them as it lands; a conversation
|
|
236
|
+
* already cached (realtime updates bring new messages without a fetch) has
|
|
237
|
+
* them sanitized here. Sanitizing is local: it sends no request.
|
|
238
|
+
*/
|
|
239
|
+
export async function prefetchConversation(
|
|
240
|
+
client: QueryClient,
|
|
241
|
+
mailboxId: string,
|
|
242
|
+
conversationId: string,
|
|
243
|
+
matchId?: string
|
|
244
|
+
) {
|
|
245
|
+
const query = conversationQuery(mailboxId, conversationId, matchId);
|
|
246
|
+
const cached = client.getQueryData(query.queryKey);
|
|
247
|
+
|
|
248
|
+
const missing =
|
|
249
|
+
matchId &&
|
|
250
|
+
cached &&
|
|
251
|
+
!cached.pages.some((page) =>
|
|
252
|
+
page.messages.some((message) => message.id === matchId)
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
await client.prefetchInfiniteQuery(
|
|
256
|
+
missing ? { ...query, staleTime: 0 } : query
|
|
257
|
+
);
|
|
258
|
+
const latestPage = client.getQueryData(query.queryKey)?.pages[0];
|
|
259
|
+
|
|
260
|
+
if (latestPage) {
|
|
261
|
+
sanitizeAhead(client, mailboxId, latestPage.messages, true, matchId);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** A mailbox's blocked senders, its own and the workspace's. */
|
|
266
|
+
export function blockedSendersQuery(mailboxId: string) {
|
|
267
|
+
return queryOptions({
|
|
268
|
+
queryKey: ["blocked-senders", mailboxId],
|
|
269
|
+
queryFn: async ({ signal }) =>
|
|
270
|
+
responseJson(
|
|
271
|
+
await mailApi.api.mail.mailboxes[":id"]["blocked-senders"].$get(
|
|
272
|
+
{ param: { id: mailboxId } },
|
|
273
|
+
{ init: { signal } }
|
|
274
|
+
)
|
|
275
|
+
),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function mailboxRulesQuery(mailboxId: string) {
|
|
280
|
+
return queryOptions({
|
|
281
|
+
queryKey: ["mailbox-rules", mailboxId],
|
|
282
|
+
queryFn: async () =>
|
|
283
|
+
responseJson(
|
|
284
|
+
await mailApi.api.mail.mailboxes[":id"].rules.$get({
|
|
285
|
+
param: { id: mailboxId },
|
|
286
|
+
})
|
|
287
|
+
),
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function mailboxAiQuery(mailboxId: string) {
|
|
292
|
+
return queryOptions({
|
|
293
|
+
queryKey: ["mailbox-ai", mailboxId],
|
|
294
|
+
queryFn: async () =>
|
|
295
|
+
responseJson(
|
|
296
|
+
await mailApi.api.mail.mailboxes[":id"].ai.$get({
|
|
297
|
+
param: { id: mailboxId },
|
|
298
|
+
})
|
|
299
|
+
),
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Loads every tab of a mailbox's "Folders & AI sorting" dialog, so none waits when picked. */
|
|
304
|
+
export function prefetchMailboxOrganization(
|
|
305
|
+
client: QueryClient,
|
|
306
|
+
mailboxId: string
|
|
307
|
+
) {
|
|
308
|
+
void client.prefetchQuery(blockedSendersQuery(mailboxId));
|
|
309
|
+
void client.prefetchQuery(mailboxRulesQuery(mailboxId));
|
|
310
|
+
void client.prefetchQuery(mailboxAiQuery(mailboxId));
|
|
311
|
+
}
|