@remit/web-client 0.0.347 → 0.0.348
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/dist/src/components/mail/BriefPane.js +3 -3
- package/dist/src/components/mail/CheckAgainProvider.d.ts +30 -0
- package/dist/src/components/mail/CheckAgainProvider.js +194 -0
- package/dist/src/components/mail/CollectionList.js +4 -2
- package/dist/src/components/mail/CollectionPane.js +3 -3
- package/dist/src/components/mail/ConversationView.d.ts +7 -8
- package/dist/src/components/mail/ConversationView.js +4 -4
- package/dist/src/components/mail/DailyBrief.js +6 -4
- package/dist/src/components/mail/IntelligencePane.d.ts +2 -2
- package/dist/src/components/mail/IntelligencePane.js +33 -4
- package/dist/src/components/mail/MailboxPane.js +10 -12
- package/dist/src/components/mail/MessageActionMenu.d.ts +3 -1
- package/dist/src/components/mail/MessageActionMenu.js +3 -3
- package/dist/src/components/mail/MessageCard.js +9 -1
- package/dist/src/components/mail/MessageList.js +11 -2
- package/dist/src/components/mail/MessageListItem.d.ts +4 -2
- package/dist/src/components/mail/MessageListItem.js +4 -6
- package/dist/src/components/mail/SpamBannerSlot.d.ts +10 -0
- package/dist/src/components/mail/SpamBannerSlot.js +56 -0
- package/dist/src/components/mail/SwipeableMessageRow.d.ts +3 -2
- package/dist/src/components/mail/SwipeableMessageRow.js +6 -6
- package/dist/src/components/mail/ThreadListInteraction.d.ts +2 -0
- package/dist/src/components/mail/ThreadListInteraction.js +12 -2
- package/dist/src/components/settings/classification/FailureBanner.js +3 -4
- package/dist/src/components/settings/spam/SpamSettingsPanel.d.ts +6 -0
- package/dist/src/components/settings/spam/SpamSettingsPanel.js +176 -0
- package/dist/src/hooks/useIntelligenceData.d.ts +2 -4
- package/dist/src/hooks/useIntelligenceData.js +1 -127
- package/dist/src/hooks/useJunkMailboxIds.d.ts +2 -0
- package/dist/src/hooks/useJunkMailboxIds.js +17 -0
- package/dist/src/lib/brief.d.ts +1 -1
- package/dist/src/lib/brief.js +3 -3
- package/dist/src/lib/check-again.d.ts +33 -0
- package/dist/src/lib/check-again.js +66 -0
- package/dist/src/lib/conversation-target.d.ts +3 -2
- package/dist/src/lib/spam-overview.d.ts +23 -0
- package/dist/src/lib/spam-overview.js +44 -0
- package/dist/src/lib/spam.d.ts +32 -0
- package/dist/src/lib/spam.js +38 -0
- package/dist/src/lib/thread-search-tokens.js +3 -1
- package/dist/src/routeTree.gen.d.ts +27 -5
- package/dist/src/routeTree.gen.js +7 -0
- package/dist/src/routes/__root.js +2 -1
- package/dist/src/routes/settings/filters.d.ts +6 -2
- package/dist/src/routes/settings/filters.js +10 -3
- package/dist/src/routes/settings/senders.d.ts +14 -2
- package/dist/src/routes/settings/senders.js +32 -15
- package/dist/src/routes/settings/spam.d.ts +1 -0
- package/dist/src/routes/settings/spam.js +15 -0
- package/dist/src/routes/settings.js +6 -1
- package/dist/src/routing/spam-link.d.ts +3 -0
- package/dist/src/routing/spam-link.js +12 -0
- package/package.json +2 -2
- package/dist/src/components/mail/AuthenticityBanner.d.ts +0 -14
- package/dist/src/components/mail/AuthenticityBanner.js +0 -18
|
@@ -4,10 +4,12 @@ import { AddressList, CollapsedMessage, cn, EmptyState, ErrorState, ExpandedMess
|
|
|
4
4
|
import { BadgeCheck, Paperclip, Star } from "@remit/ui/icons";
|
|
5
5
|
import { useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { useState } from "react";
|
|
7
|
+
import { useJunkMailboxIds } from "../../hooks/useJunkMailboxIds";
|
|
7
8
|
import { toDisplayCategory } from "../../lib/display-category";
|
|
8
9
|
import { formatDatePreset } from "../../lib/format";
|
|
9
10
|
import { isMessageGoneFromServerError, isMessageNotFoundError, } from "../ui/error-banners";
|
|
10
11
|
import { AutoMovedIndicator } from "./AutoMovedIndicator";
|
|
12
|
+
import { checkAgainRequestOfThread, useCheckAgain } from "./CheckAgainProvider";
|
|
11
13
|
import { MessageActionMenu } from "./MessageActionMenu";
|
|
12
14
|
import { MessageAttachments } from "./MessageAttachments";
|
|
13
15
|
import { MessageBody } from "./MessageBody";
|
|
@@ -43,6 +45,8 @@ const CollapsedCard = ({ threadMessage, isFocused, onToggle, onToggleStar, isSta
|
|
|
43
45
|
return (_jsx(CollapsedMessage, { message: message, onClick: onToggle, isFocused: isFocused, isUnread: !threadMessage.isRead, trailing: _jsxs(_Fragment, { children: [threadMessage.hasAttachment && (_jsx(Paperclip, { className: "size-3 shrink-0 text-fg-subtle", role: "img", "aria-label": "Has an attachment" })), _jsx(StarButton, { isStarred: threadMessage.hasStars, onToggleStar: onToggleStar, isStarPending: isStarPending, hoverReveal: true }), _jsx("span", { "data-testid": "message-date", className: "shrink-0 text-2xs text-fg-subtle tabular-nums", children: date })] }) }));
|
|
44
46
|
};
|
|
45
47
|
const ExpandedCard = ({ threadMessage, messageData, isLoading, isError, error, onRetry, isFocused, onToggle, onToggleStar, isStarPending, accountId, showRaw, onToggleRaw, mobile, onReply, onReplyAll, onForward, }) => {
|
|
48
|
+
const checkAgain = useCheckAgain();
|
|
49
|
+
const junkMailboxIds = useJunkMailboxIds();
|
|
46
50
|
const date = formatDatePreset(threadMessage.sentDate, "long");
|
|
47
51
|
const isUnread = !threadMessage.isRead;
|
|
48
52
|
const isTrusted = messageData?.envelope.from[0]?.flags?.trusted?.value === true;
|
|
@@ -56,7 +60,11 @@ const ExpandedCard = ({ threadMessage, messageData, isLoading, isError, error, o
|
|
|
56
60
|
const autoMovedNode = threadMessage.autoMoved || threadMessage.spamReport ? (_jsx(AutoMovedIndicator, { accountId: accountId, messageId: threadMessage.messageId, threadId: threadMessage.threadId, mailboxId: threadMessage.mailboxId, autoMoved: threadMessage.autoMoved, spamReport: threadMessage.spamReport })) : null;
|
|
57
61
|
return (_jsx(ExpandedMessage, { message: message, isFocused: mobile ? false : isFocused, onHeaderClick: onToggle, senderBadge: isTrusted && !isBlocked ? _jsx(TrustedSenderBadge, {}) : undefined, trailing: _jsx("span", { "data-testid": "message-date", className: "text-2xs text-fg-subtle", children: date }), to: messageData ? (_jsx(AddressList, { label: "To", addresses: messageData.envelope.to })) : null, indicators: autoMovedNode || !mobile ? (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5 mt-0.5", children: [autoMovedNode, !mobile && (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex items-center justify-end gap-1", children: _jsx(StarButton, { isStarred: threadMessage.hasStars, onToggleStar: onToggleStar, isStarPending: isStarPending }) }), isUnread && (
|
|
58
62
|
// biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-label on decorative indicator provides useful context for assistive tech
|
|
59
|
-
_jsx("span", { className: "size-1.5 rounded-full bg-accent", "aria-label": "Unread" }))] }))] })) : undefined, actionMenu: mobile ? undefined : (_jsx(MessageActionMenu, { messageId: threadMessage.messageId, threadId: threadMessage.threadId, mailboxId: threadMessage.mailboxId, isRead: threadMessage.isRead, accountId: accountId, fromAddressId: fromAddressId, isTrusted: isTrusted, showRaw: showRaw, onToggleRaw: onToggleRaw
|
|
63
|
+
_jsx("span", { className: "size-1.5 rounded-full bg-accent", "aria-label": "Unread" }))] }))] })) : undefined, actionMenu: mobile ? undefined : (_jsx(MessageActionMenu, { messageId: threadMessage.messageId, threadId: threadMessage.threadId, mailboxId: threadMessage.mailboxId, isRead: threadMessage.isRead, accountId: accountId, fromAddressId: fromAddressId, isTrusted: isTrusted, showRaw: showRaw, onToggleRaw: onToggleRaw, onCheckAgain: checkAgain
|
|
64
|
+
? () => checkAgain.checkAgain([
|
|
65
|
+
checkAgainRequestOfThread(threadMessage, junkMailboxIds),
|
|
66
|
+
], { panel: false })
|
|
67
|
+
: undefined })), actionBar: mobile ? (_jsx(MobileMessageBar, { messageId: threadMessage.messageId, threadId: threadMessage.threadId, mailboxId: threadMessage.mailboxId, accountId: accountId, isRead: threadMessage.isRead, isStarred: threadMessage.hasStars, onToggleStar: onToggleStar, fromAddressId: fromAddressId, isTrusted: isTrusted, showRaw: showRaw, onToggleRaw: onToggleRaw, onReply: onReply, onReplyAll: onReplyAll, onForward: onForward })) : undefined, body: _jsxs(_Fragment, { children: [_jsx(MessageSettlementAlert, { threadMessage: threadMessage, accountId: accountId, className: "mt-3" }), isLoading ? (_jsxs("div", { className: "mt-3 animate-pulse space-y-2", children: [_jsx("div", { className: "h-4 bg-surface-sunken rounded w-full" }), _jsx("div", { className: "h-4 bg-surface-sunken rounded w-3/4" }), _jsx("div", { className: "h-4 bg-surface-sunken rounded w-1/2" })] })) : isError && isMessageGoneFromServerError(error) ? (_jsx("div", { className: "mt-3", children: _jsx(EmptyState, { message: "This message is no longer on the mail server. It was moved or deleted in another mail app." }) })) : isError && isMessageNotFoundError(error) ? (_jsx("div", { className: "mt-3", children: _jsx(EmptyState, { message: "This message has been deleted" }) })) : isError ? (_jsx("div", { className: "mt-3", children: _jsx(ErrorState, { variant: "inline", title: "Couldn't load this message", error: error, onRetry: onRetry }) })) : showRaw ? (_jsx("div", { className: "mt-3", children: _jsx(RawMessageView, { messageId: threadMessage.messageId }) })) : (_jsxs("div", { className: "mt-3", children: [_jsx(MessageBody, { bodyParts: messageData?.bodyParts, messageId: threadMessage.messageId, fromAddressId: messageData?.envelope.from[0]?.addressId, isTrusted: isTrusted, isBlocked: isBlocked, category: toDisplayCategory(threadMessage.category) }), _jsx(MessageAttachments, { messageId: threadMessage.messageId, bodyParts: messageData?.bodyParts, hasAttachment: threadMessage.hasAttachment, className: "mt-4" })] }))] }) }));
|
|
60
68
|
};
|
|
61
69
|
export const MessageCard = ({ threadMessage, isExpanded, isFocused, onToggle, onToggleStar, isStarPending, accountId, mobile, onReply, onReplyAll, onForward, }) => {
|
|
62
70
|
const [showRaw, setShowRaw] = useState(false);
|
|
@@ -7,6 +7,7 @@ import { useJunkMailbox } from "../../hooks/useArchiveMailbox";
|
|
|
7
7
|
import { useDeleteOutcome } from "../../hooks/useDeleteOutcome";
|
|
8
8
|
import { useEscalatedActions, } from "../../hooks/useEscalatedActions";
|
|
9
9
|
import { useFollowFocusOpen } from "../../hooks/useFollowFocusOpen";
|
|
10
|
+
import { useJunkMailboxIds } from "../../hooks/useJunkMailboxIds";
|
|
10
11
|
import { useLabelList } from "../../hooks/useLabels";
|
|
11
12
|
import { useToggleReadFor } from "../../hooks/useMarkAsRead";
|
|
12
13
|
import { useIsDesktop } from "../../hooks/useMediaQuery";
|
|
@@ -22,6 +23,7 @@ import { resolveSelectionAccountScope } from "../../lib/selection-account-scope"
|
|
|
22
23
|
import { shouldExitSelectionOnNavigate } from "../../lib/selection-mode";
|
|
23
24
|
import { useOpenThread, useSelectionWizard, useWizardStepValue, } from "../../routing";
|
|
24
25
|
import { useErrorBanners } from "../ui/error-banner-context";
|
|
26
|
+
import { checkAgainRequestOfThread, useCheckAgain } from "./CheckAgainProvider";
|
|
25
27
|
import { DeleteConfirmDialog } from "./DeleteConfirmDialog";
|
|
26
28
|
import { LabelApplyTrigger } from "./LabelApplyTrigger";
|
|
27
29
|
import { SelectionWizardHost, } from "./SelectionWizardHost";
|
|
@@ -268,6 +270,13 @@ export const MessageList = ({ mailboxId, threads, selectedMessageId, isLoading,
|
|
|
268
270
|
}
|
|
269
271
|
return rows;
|
|
270
272
|
}, [threads, selectedIds, accountId]);
|
|
273
|
+
const checkAgain = useCheckAgain();
|
|
274
|
+
const junkMailboxIds = useJunkMailboxIds();
|
|
275
|
+
const checkAgainSelection = checkAgain
|
|
276
|
+
? () => checkAgain.checkAgain(threads
|
|
277
|
+
.filter((thread) => selectedIds.has(thread.messageId))
|
|
278
|
+
.map((thread) => checkAgainRequestOfThread(thread, junkMailboxIds)), { panel: true })
|
|
279
|
+
: undefined;
|
|
271
280
|
const handleRowSelect = useCallback((messageId, modifiers) => {
|
|
272
281
|
if (modifiers.shiftKey) {
|
|
273
282
|
// The open/focused row is the fallback origin when the stored anchor
|
|
@@ -860,7 +869,7 @@ export const MessageList = ({ mailboxId, threads, selectedMessageId, isLoading,
|
|
|
860
869
|
// title's place, and the escalation states (issue #212) — the offer,
|
|
861
870
|
// counting, the escalated predicate, a chunked run's progress — ride on the
|
|
862
871
|
// same bar rather than a second one.
|
|
863
|
-
const activeSelectionBar = (_jsx(SelectionTopBar, { title: listHeaderChrome.title || listTitle, navSlot: listHeaderChrome.navSlot, titleMeta: listHeaderChrome.titleMeta, searchSlot: listHeaderChrome.searchSlot, searchField: listHeaderChrome.searchField, idleSlot: listHeaderChrome.makeFilterSlot, count: selectionCount, onCancel: handleSelectionCancel, onDelete: () => startWizard("delete"), onMove: () => startWizard("move"), onOrganize: organizeSelection, onJunk: junkDestinationId ? () => startWizard("junk") : undefined, onMarkRead: () => startWizard("markRead"), overflowSlot: accountId && mailboxId && selectedCount > 0 && labels.length > 0 ? (_jsx(LabelApplyTrigger, { accountId: accountId, mailboxId: mailboxId, messageIds: Array.from(selectedIds) })) : undefined, isBusy: selectionIsBusy, isCounting: escalation.phase.kind === "counting", selectAll: selectionSelectAll, statusLabel: selectionStatusLabel, progress: selectionProgress, notice: selectionNotice }));
|
|
872
|
+
const activeSelectionBar = (_jsx(SelectionTopBar, { title: listHeaderChrome.title || listTitle, navSlot: listHeaderChrome.navSlot, titleMeta: listHeaderChrome.titleMeta, searchSlot: listHeaderChrome.searchSlot, searchField: listHeaderChrome.searchField, idleSlot: listHeaderChrome.makeFilterSlot, count: selectionCount, onCancel: handleSelectionCancel, onDelete: () => startWizard("delete"), onMove: () => startWizard("move"), onOrganize: organizeSelection, onJunk: junkDestinationId ? () => startWizard("junk") : undefined, onMarkRead: () => startWizard("markRead"), onCheckAgain: checkAgainSelection, overflowSlot: accountId && mailboxId && selectedCount > 0 && labels.length > 0 ? (_jsx(LabelApplyTrigger, { accountId: accountId, mailboxId: mailboxId, messageIds: Array.from(selectedIds) })) : undefined, isBusy: selectionIsBusy, isCounting: escalation.phase.kind === "counting", selectAll: selectionSelectAll, statusLabel: selectionStatusLabel, progress: selectionProgress, notice: selectionNotice }));
|
|
864
873
|
// Roving tabindex: exactly one row is in the tab order, so Tab moves focus
|
|
865
874
|
// into the list at the cursor and Shift+Tab moves back out to the side panel
|
|
866
875
|
// instead of walking every row (#43).
|
|
@@ -883,7 +892,7 @@ export const MessageList = ({ mailboxId, threads, selectedMessageId, isLoading,
|
|
|
883
892
|
// #92) — the number in the bar and the rows underneath
|
|
884
893
|
// have to agree something is happening, and a row mid
|
|
885
894
|
// -delete must not be openable.
|
|
886
|
-
escalation.isRunning && "pointer-events-none opacity-50"), style: { transform: `translateY(${virtualRow.start}px)` }, children: _jsx(SwipeableMessageRow, { thread: thread, mailboxId: mailboxId, isSelected: selectedMessageId === thread.messageId, isFocused: focusedMessageId === thread.messageId, isTabStop: tabStopMessageId === thread.messageId, onFocusRow: handleRowFocus, isChecked: isChecked(thread.messageId), onToggleCheck: toggleCheck, onRowSelect: handleRowSelect, isMultiSelectMode: isMultiSelectMode, onLongPress: handleLongPress, isDesktop: isDesktop, onDelete: handleSwipeDelete, onToggleRead: handleSwipeToggleRead, density: density }) }, virtualRow.key));
|
|
895
|
+
escalation.isRunning && "pointer-events-none opacity-50"), style: { transform: `translateY(${virtualRow.start}px)` }, children: _jsx(SwipeableMessageRow, { thread: thread, mailboxId: mailboxId, junkMailboxIds: junkMailboxIds, isSelected: selectedMessageId === thread.messageId, isFocused: focusedMessageId === thread.messageId, isTabStop: tabStopMessageId === thread.messageId, onFocusRow: handleRowFocus, isChecked: isChecked(thread.messageId), onToggleCheck: toggleCheck, onRowSelect: handleRowSelect, isMultiSelectMode: isMultiSelectMode, onLongPress: handleLongPress, isDesktop: isDesktop, onDelete: handleSwipeDelete, onToggleRead: handleSwipeToggleRead, density: density }) }, virtualRow.key));
|
|
887
896
|
}) }), isLoadingMore && _jsx(MessageListLoadingMore, {})] })] }));
|
|
888
897
|
return (_jsxs(_Fragment, { children: [completionBanner && !isDesktop && (_jsx(Banner, { tone: "success", variant: "soft", className: "m-2 rounded-md", onDismiss: () => setCompletionBanner(null), children: completionBanner })), _jsx(MessageListPane, { listTitle: listTitle, listMeta: listMeta, sections: sections, flatList: true,
|
|
889
898
|
// The results panel is a body, not a list state: it stands in for the
|
|
@@ -10,6 +10,8 @@ import type { Density, SelectionModifiers, ThreadRowData } from "@remit/ui";
|
|
|
10
10
|
interface MessageListItemProps {
|
|
11
11
|
thread: RemitImapThreadMessageResponse;
|
|
12
12
|
mailboxId: string;
|
|
13
|
+
/** Every account's Spam folder, which tells a moved row from a suspected one. */
|
|
14
|
+
junkMailboxIds: ReadonlySet<string>;
|
|
13
15
|
isSelected: boolean;
|
|
14
16
|
isFocused?: boolean;
|
|
15
17
|
isTabStop?: boolean;
|
|
@@ -27,6 +29,6 @@ interface MessageListItemProps {
|
|
|
27
29
|
* Map a RemitImapThreadMessageResponse to the ThreadRowData shape the shared
|
|
28
30
|
* row renders.
|
|
29
31
|
*/
|
|
30
|
-
export declare const threadToRowData: (thread: RemitImapThreadMessageResponse, messageCount?: number) => ThreadRowData;
|
|
31
|
-
export declare const MessageListItem: import("react").MemoExoticComponent<({ thread, mailboxId, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, messageCount, isMultiSelectMode, onLongPress, isDesktop, density, }: MessageListItemProps) => import("react").JSX.Element>;
|
|
32
|
+
export declare const threadToRowData: (thread: RemitImapThreadMessageResponse, junkMailboxIds: ReadonlySet<string>, messageCount?: number) => ThreadRowData;
|
|
33
|
+
export declare const MessageListItem: import("react").MemoExoticComponent<({ thread, mailboxId, junkMailboxIds, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, messageCount, isMultiSelectMode, onLongPress, isDesktop, density, }: MessageListItemProps) => import("react").JSX.Element>;
|
|
32
34
|
export {};
|
|
@@ -3,12 +3,13 @@ import { memo } from "react";
|
|
|
3
3
|
import { toDisplayCategory } from "../../lib/display-category";
|
|
4
4
|
import { formatEmailDate } from "../../lib/format";
|
|
5
5
|
import { rowSettlement } from "../../lib/row-settlement";
|
|
6
|
+
import { spamRowMark } from "../../lib/spam";
|
|
6
7
|
import { MessageRow } from "./MessageRow";
|
|
7
8
|
/**
|
|
8
9
|
* Map a RemitImapThreadMessageResponse to the ThreadRowData shape the shared
|
|
9
10
|
* row renders.
|
|
10
11
|
*/
|
|
11
|
-
export const threadToRowData = (thread, messageCount) => ({
|
|
12
|
+
export const threadToRowData = (thread, junkMailboxIds, messageCount) => ({
|
|
12
13
|
id: thread.messageId,
|
|
13
14
|
accountId: thread.accountId,
|
|
14
15
|
mailboxId: thread.mailboxId,
|
|
@@ -24,14 +25,11 @@ export const threadToRowData = (thread, messageCount) => ({
|
|
|
24
25
|
trust: thread.senderTrust,
|
|
25
26
|
category: toDisplayCategory(thread.category),
|
|
26
27
|
messageCount,
|
|
27
|
-
|
|
28
|
-
// for the multi-signature / alignment semantics a single string compare
|
|
29
|
-
// misses.
|
|
30
|
-
suspicious: thread.authenticity?.dkimMismatch === true,
|
|
28
|
+
spam: spamRowMark(thread, junkMailboxIds),
|
|
31
29
|
labels: thread.labels,
|
|
32
30
|
...rowSettlement(thread),
|
|
33
31
|
});
|
|
34
|
-
const MessageListItemComponent = ({ thread, mailboxId, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, messageCount, isMultiSelectMode, onLongPress, isDesktop, density, }) => (_jsx(MessageRow, { thread: threadToRowData(thread, messageCount), link: { mailboxId, threadId: thread.threadId }, inListbox: true, active: isSelected, focused: isFocused, isTabStop: isTabStop, density: density, isDesktop: isDesktop, onFocusRow: onFocusRow, selection: {
|
|
32
|
+
const MessageListItemComponent = ({ thread, mailboxId, junkMailboxIds, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, messageCount, isMultiSelectMode, onLongPress, isDesktop, density, }) => (_jsx(MessageRow, { thread: threadToRowData(thread, junkMailboxIds, messageCount), link: { mailboxId, threadId: thread.threadId }, inListbox: true, active: isSelected, focused: isFocused, isTabStop: isTabStop, density: density, isDesktop: isDesktop, onFocusRow: onFocusRow, selection: {
|
|
35
33
|
isChecked,
|
|
36
34
|
onToggleCheck,
|
|
37
35
|
onRowSelect,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
+
/**
|
|
3
|
+
* The message view's one banner slot, between the header and the body. It
|
|
4
|
+
* warns while the message carries a Remit Spam or Phishing label outside Spam,
|
|
5
|
+
* or when the check failed, and goes when the label goes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SpamBannerSlot({ row, onOpenIntelligence, }: {
|
|
8
|
+
row: RemitImapThreadMessageResponse;
|
|
9
|
+
onOpenIntelligence?: () => void;
|
|
10
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SpamWarningBanner } from "@remit/ui";
|
|
3
|
+
import { useJunkMailbox } from "../../hooks/useArchiveMailbox";
|
|
4
|
+
import { useMoveMessages } from "../../hooks/useMoveMessages";
|
|
5
|
+
import { useReportSpam } from "../../hooks/useReportSpam";
|
|
6
|
+
import { raisesSpamWarning } from "../../lib/spam";
|
|
7
|
+
import { useErrorBanners } from "../ui/error-banner-context";
|
|
8
|
+
import { checkAgainRequestOfThread, useCheckAgain } from "./CheckAgainProvider";
|
|
9
|
+
/**
|
|
10
|
+
* The message view's one banner slot, between the header and the body. It
|
|
11
|
+
* warns while the message carries a Remit Spam or Phishing label outside Spam,
|
|
12
|
+
* or when the check failed, and goes when the label goes.
|
|
13
|
+
*/
|
|
14
|
+
export function SpamBannerSlot({ row, onOpenIntelligence, }) {
|
|
15
|
+
const { accountId } = row;
|
|
16
|
+
const { junkMailboxId } = useJunkMailbox(accountId);
|
|
17
|
+
const checkAgain = useCheckAgain();
|
|
18
|
+
const { pushError } = useErrorBanners();
|
|
19
|
+
const { reportSpam, notSpam, isReporting, isRestoring } = useReportSpam({
|
|
20
|
+
mailboxId: row.mailboxId,
|
|
21
|
+
threadId: row.threadId,
|
|
22
|
+
accountId,
|
|
23
|
+
});
|
|
24
|
+
const { moveMessages, isPending: isMoving } = useMoveMessages({
|
|
25
|
+
mailboxId: row.mailboxId,
|
|
26
|
+
threadId: row.threadId,
|
|
27
|
+
accountId,
|
|
28
|
+
});
|
|
29
|
+
const verdict = row.spamVerdict;
|
|
30
|
+
const inSpamFolder = junkMailboxId !== undefined && row.mailboxId === junkMailboxId;
|
|
31
|
+
if (!raisesSpamWarning(row, inSpamFolder))
|
|
32
|
+
return null;
|
|
33
|
+
if (verdict.state !== "Checked" && verdict.state !== "Failed")
|
|
34
|
+
return null;
|
|
35
|
+
const pending = checkAgain?.pendingIds.has(row.messageId)
|
|
36
|
+
? "CheckAgain"
|
|
37
|
+
: isReporting
|
|
38
|
+
? "Report"
|
|
39
|
+
: isRestoring
|
|
40
|
+
? "NotSpam"
|
|
41
|
+
: isMoving
|
|
42
|
+
? "Move"
|
|
43
|
+
: undefined;
|
|
44
|
+
return (_jsx(SpamWarningBanner, { verdict: verdict, inSpamFolder: inSpamFolder, pending: pending, checkAgainFailure: checkAgain?.failures.get(row.messageId), onNotSpam: () => notSpam([row.messageId]), onReport: () => reportSpam([row.messageId]), onMove: () => {
|
|
45
|
+
if (junkMailboxId) {
|
|
46
|
+
moveMessages([row.messageId], junkMailboxId);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
pushError({
|
|
50
|
+
title: "Couldn't move this message to Spam",
|
|
51
|
+
detail: "This account has no Spam folder yet. Choose one in Settings, Folder roles.",
|
|
52
|
+
});
|
|
53
|
+
}, onWhy: () => onOpenIntelligence?.(), onCheckAgain: () => checkAgain?.checkAgain([
|
|
54
|
+
checkAgainRequestOfThread(row, junkMailboxId ? new Set([junkMailboxId]) : new Set()),
|
|
55
|
+
], { panel: false }) }));
|
|
56
|
+
}
|
|
@@ -3,6 +3,7 @@ import { type Density, type SelectionModifiers, type ThreadRowData } from "@remi
|
|
|
3
3
|
interface SwipeableMessageRowProps {
|
|
4
4
|
thread: RemitImapThreadMessageResponse;
|
|
5
5
|
mailboxId: string;
|
|
6
|
+
junkMailboxIds: ReadonlySet<string>;
|
|
6
7
|
isSelected: boolean;
|
|
7
8
|
/** Roving keyboard focus cursor — renders the left accent rail (#429). */
|
|
8
9
|
isFocused?: boolean;
|
|
@@ -26,6 +27,6 @@ interface SwipeableMessageRowProps {
|
|
|
26
27
|
* so every row signal has to be repeated here. Exported so a test can hold it
|
|
27
28
|
* to the same answers as the desktop mapper.
|
|
28
29
|
*/
|
|
29
|
-
export declare const swipeableRowData: (thread: RemitImapThreadMessageResponse) => ThreadRowData;
|
|
30
|
-
export declare const SwipeableMessageRow: ({ thread, mailboxId, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, isMultiSelectMode, onLongPress, isDesktop, onDelete, onToggleRead, density, }: SwipeableMessageRowProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const swipeableRowData: (thread: RemitImapThreadMessageResponse, junkMailboxIds: ReadonlySet<string>) => ThreadRowData;
|
|
31
|
+
export declare const SwipeableMessageRow: ({ thread, mailboxId, junkMailboxIds, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, isMultiSelectMode, onLongPress, isDesktop, onDelete, onToggleRead, density, }: SwipeableMessageRowProps) => import("react").JSX.Element;
|
|
31
32
|
export {};
|
|
@@ -4,6 +4,7 @@ import { useCallback, useState } from "react";
|
|
|
4
4
|
import { toDisplayCategory } from "../../lib/display-category";
|
|
5
5
|
import { formatEmailDate } from "../../lib/format";
|
|
6
6
|
import { rowSettlement } from "../../lib/row-settlement";
|
|
7
|
+
import { spamRowMark } from "../../lib/spam";
|
|
7
8
|
import { useOpenThread } from "../../routing";
|
|
8
9
|
import { MessageListItem } from "./MessageListItem";
|
|
9
10
|
import { useModifierSelect } from "./useModifierSelect";
|
|
@@ -13,8 +14,7 @@ import { useModifierSelect } from "./useModifierSelect";
|
|
|
13
14
|
* so every row signal has to be repeated here. Exported so a test can hold it
|
|
14
15
|
* to the same answers as the desktop mapper.
|
|
15
16
|
*/
|
|
16
|
-
export const swipeableRowData = (thread) => {
|
|
17
|
-
const suspicious = thread.authenticity?.dkimMismatch === true;
|
|
17
|
+
export const swipeableRowData = (thread, junkMailboxIds) => {
|
|
18
18
|
return {
|
|
19
19
|
id: thread.messageId,
|
|
20
20
|
accountId: thread.accountId,
|
|
@@ -28,11 +28,11 @@ export const swipeableRowData = (thread) => {
|
|
|
28
28
|
starred: thread.hasStars === true,
|
|
29
29
|
trust: thread.senderTrust,
|
|
30
30
|
category: toDisplayCategory(thread.category),
|
|
31
|
-
|
|
31
|
+
spam: spamRowMark(thread, junkMailboxIds),
|
|
32
32
|
...rowSettlement(thread),
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
export const SwipeableMessageRow = ({ thread, mailboxId, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, isMultiSelectMode, onLongPress, isDesktop, onDelete, onToggleRead, density, }) => {
|
|
35
|
+
export const SwipeableMessageRow = ({ thread, mailboxId, junkMailboxIds, isSelected, isFocused, isTabStop, onFocusRow, isChecked, onToggleCheck, onRowSelect, isMultiSelectMode, onLongPress, isDesktop, onDelete, onToggleRead, density, }) => {
|
|
36
36
|
const [peek, setPeek] = useState("none");
|
|
37
37
|
const openThread = useOpenThread();
|
|
38
38
|
const handleAct = useCallback((side) => {
|
|
@@ -56,7 +56,7 @@ export const SwipeableMessageRow = ({ thread, mailboxId, isSelected, isFocused,
|
|
|
56
56
|
}, [openThread, thread.threadId, thread.messageId]);
|
|
57
57
|
const modifierSelect = useModifierSelect(thread.messageId, onRowSelect);
|
|
58
58
|
if (isDesktop || isMultiSelectMode) {
|
|
59
|
-
return (_jsx(MessageListItem, { thread: thread, mailboxId: mailboxId, isSelected: isSelected, isFocused: isFocused, isTabStop: isTabStop, onFocusRow: onFocusRow, isChecked: isChecked, onToggleCheck: onToggleCheck, onRowSelect: onRowSelect, isMultiSelectMode: isMultiSelectMode, onLongPress: onLongPress, isDesktop: isDesktop, density: density }));
|
|
59
|
+
return (_jsx(MessageListItem, { thread: thread, mailboxId: mailboxId, junkMailboxIds: junkMailboxIds, isSelected: isSelected, isFocused: isFocused, isTabStop: isTabStop, onFocusRow: onFocusRow, isChecked: isChecked, onToggleCheck: onToggleCheck, onRowSelect: onRowSelect, isMultiSelectMode: isMultiSelectMode, onLongPress: onLongPress, isDesktop: isDesktop, density: density }));
|
|
60
60
|
}
|
|
61
61
|
// The swipe row reads the press as a pointer gesture, and it opens the message
|
|
62
62
|
// from the release — a `mousedown` handler on the row would already be behind
|
|
@@ -65,5 +65,5 @@ export const SwipeableMessageRow = ({ thread, mailboxId, isSelected, isFocused,
|
|
|
65
65
|
// swipe, a long press or an open.
|
|
66
66
|
return (
|
|
67
67
|
// biome-ignore lint/a11y/noStaticElementInteractions: the wrapper only intercepts mouse modifiers ahead of the row's own gesture; the row beneath keeps the button semantics and the whole keyboard path
|
|
68
|
-
_jsx("div", { role: "presentation", onPointerDownCapture: modifierSelect.onMouseDown, onClickCapture: modifierSelect.claimClick, onContextMenu: modifierSelect.onContextMenu, children: _jsx(SwipeableRow, { thread: swipeableRowData(thread), selectionMode: false, checked: false, active: isSelected, peek: peek, onPeek: setPeek, onToggleCheck: handleToggleCheck, onLongPress: handleLongPress, onOpen: handleOpen, onAct: handleAct }) }));
|
|
68
|
+
_jsx("div", { role: "presentation", onPointerDownCapture: modifierSelect.onMouseDown, onClickCapture: modifierSelect.claimClick, onContextMenu: modifierSelect.onContextMenu, children: _jsx(SwipeableRow, { thread: swipeableRowData(thread, junkMailboxIds), selectionMode: false, checked: false, active: isSelected, peek: peek, onPeek: setPeek, onToggleCheck: handleToggleCheck, onLongPress: handleLongPress, onOpen: handleOpen, onAct: handleAct }) }));
|
|
69
69
|
};
|
|
@@ -45,6 +45,8 @@ interface ThreadListInteractionValue {
|
|
|
45
45
|
allSelected: boolean;
|
|
46
46
|
/** Select every rendered row, or clear when they already all are. */
|
|
47
47
|
toggleAllLoaded: () => void;
|
|
48
|
+
/** Checks the selection for spam again. Absent outside the app shell. */
|
|
49
|
+
checkAgainSelection: (() => void) | undefined;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* Per-row cursor/selection state, or null outside a provider — the mailbox list
|
|
@@ -25,6 +25,7 @@ import { useIsDesktop } from "../../hooks/useMediaQuery";
|
|
|
25
25
|
import { tabStopId } from "../../lib/list-focus";
|
|
26
26
|
import { useListHeaderChrome } from "../../lib/list-header-chrome";
|
|
27
27
|
import { useErrorBanners } from "../ui/error-banner-context";
|
|
28
|
+
import { checkAgainRequestOfRow, useCheckAgain } from "./CheckAgainProvider";
|
|
28
29
|
import { DeleteConfirmDialog } from "./DeleteConfirmDialog";
|
|
29
30
|
/** Nothing pending, as a stable identity so the outcome memo does not churn. */
|
|
30
31
|
const NO_TARGETS = [];
|
|
@@ -255,7 +256,15 @@ export function ThreadListInteraction({ selectedMessageId, rows, onOpen, onDelet
|
|
|
255
256
|
hasList,
|
|
256
257
|
]);
|
|
257
258
|
const tabStop = tabStopId(orderedIds, focusedMessageId);
|
|
259
|
+
const checkAgain = useCheckAgain();
|
|
260
|
+
const checkAgainSelection = useMemo(() => checkAgain
|
|
261
|
+
? () => checkAgain.checkAgain(rows
|
|
262
|
+
.filter((row) => selectedIds.has(row.id))
|
|
263
|
+
.map(checkAgainRequestOfRow)
|
|
264
|
+
.filter((request) => request !== undefined), { panel: true })
|
|
265
|
+
: undefined, [checkAgain, rows, selectedIds]);
|
|
258
266
|
const value = useMemo(() => ({
|
|
267
|
+
checkAgainSelection,
|
|
259
268
|
selectedIds,
|
|
260
269
|
selectedCount,
|
|
261
270
|
exitSelection,
|
|
@@ -277,6 +286,7 @@ export function ThreadListInteraction({ selectedMessageId, rows, onOpen, onDelet
|
|
|
277
286
|
},
|
|
278
287
|
}),
|
|
279
288
|
}), [
|
|
289
|
+
checkAgainSelection,
|
|
280
290
|
selectedIds,
|
|
281
291
|
selectedCount,
|
|
282
292
|
exitSelection,
|
|
@@ -308,8 +318,8 @@ export function ThreadListInteraction({ selectedMessageId, rows, onOpen, onDelet
|
|
|
308
318
|
*/
|
|
309
319
|
export function ThreadListSelectionBar({ title, isDeleting, }) {
|
|
310
320
|
const chrome = useListHeaderChrome();
|
|
311
|
-
const { selectedCount, exitSelection, startSelectionVerb, orderedIds, allSelected, toggleAllLoaded, } = useThreadListSelection();
|
|
312
|
-
return (_jsx(SelectionTopBar, { title: chrome.title || title, navSlot: chrome.navSlot, titleMeta: chrome.titleMeta, searchSlot: chrome.searchSlot, searchField: chrome.searchField, idleSlot: chrome.makeFilterSlot, count: selectedCount, onCancel: exitSelection, onDelete: () => startSelectionVerb("delete"), onMarkRead: () => startSelectionVerb("markRead"), isBusy: isDeleting, selectAll: orderedIds.length > 0
|
|
321
|
+
const { selectedCount, exitSelection, startSelectionVerb, orderedIds, allSelected, toggleAllLoaded, checkAgainSelection, } = useThreadListSelection();
|
|
322
|
+
return (_jsx(SelectionTopBar, { title: chrome.title || title, navSlot: chrome.navSlot, titleMeta: chrome.titleMeta, searchSlot: chrome.searchSlot, searchField: chrome.searchField, idleSlot: chrome.makeFilterSlot, count: selectedCount, onCancel: exitSelection, onDelete: () => startSelectionVerb("delete"), onMarkRead: () => startSelectionVerb("markRead"), onCheckAgain: checkAgainSelection, isBusy: isDeleting, selectAll: orderedIds.length > 0
|
|
313
323
|
? {
|
|
314
324
|
checked: allSelected,
|
|
315
325
|
indeterminate: selectedCount > 0 && !allSelected,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { formatErrorMessage, FailureBanner as SectionFailureBanner, } from "@remit/ui";
|
|
3
3
|
import { classificationReportHref } from "../../../lib/classification";
|
|
4
|
-
import { ReportLink } from "../ReportLink";
|
|
5
4
|
export function FailureBanner({ failure, onRetry, }) {
|
|
6
5
|
const message = formatErrorMessage(failure.error);
|
|
7
|
-
return (
|
|
6
|
+
return (_jsx(SectionFailureBanner, { title: failure.title, message: message, reportHref: classificationReportHref(failure.title, message), onRetry: onRetry }));
|
|
8
7
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Spam & phishing settings at `/settings/spam`: what Remit flagged in the
|
|
3
|
+
* last 30 days, the thresholds in effect, the per-label action and the sender
|
|
4
|
+
* groups. Every section loads and fails on its own.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SpamSettingsPanel(): import("react").JSX.Element;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { classificationStatsOperationsGetClassificationStatsOptions, configOperationsGetConfigOptions, userSettingsOperationsGetUserSettingsOptions, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
3
|
+
import { unifiedThreadOperationsListAllThreads } from "@remit/api-http-client/sdk.gen.ts";
|
|
4
|
+
import { buttonClassName, cn, FailureBanner, formatErrorMessage, formatSpamScore, LabelChip, SegmentedControl, SpamDailyChart, topSpamReasonSentence, } from "@remit/ui";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useId, useState } from "react";
|
|
7
|
+
import { useSaveClassification } from "../../../hooks/useClassificationSettings";
|
|
8
|
+
import { useJunkMailboxIds } from "../../../hooks/useJunkMailboxIds";
|
|
9
|
+
import { useLabelList } from "../../../hooks/useLabels";
|
|
10
|
+
import { isUnauthenticated, softErrorStatuses, } from "../../../lib/error-classifier";
|
|
11
|
+
import { formatEmailDate } from "../../../lib/format";
|
|
12
|
+
import { flaggedVerdict, remitSpamLabel, spamReportHref, } from "../../../lib/spam";
|
|
13
|
+
import { buildSpamOverview, overviewDays, spamOverviewSince, } from "../../../lib/spam-overview";
|
|
14
|
+
import { NavLink } from "../../../routing";
|
|
15
|
+
const SECTION_TITLE = "text-xs font-semibold uppercase tracking-wider text-fg-subtle";
|
|
16
|
+
const sectionMeta = softErrorStatuses(400, 403, 404);
|
|
17
|
+
const LATEST_COUNT = 10;
|
|
18
|
+
function Section({ title, children, aside, }) {
|
|
19
|
+
const id = useId();
|
|
20
|
+
return (_jsxs("section", { "aria-labelledby": id, className: "space-y-3", children: [_jsxs("div", { className: "flex flex-wrap items-baseline justify-between gap-2", children: [_jsx("h2", { id: id, className: SECTION_TITLE, children: title }), aside] }), children] }));
|
|
21
|
+
}
|
|
22
|
+
function Skeleton({ className }) {
|
|
23
|
+
return (_jsx("div", { "aria-hidden": "true", className: cn("animate-pulse rounded-md bg-surface-sunken", className) }));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A section's load failure. An expired session raises the signed-out notice
|
|
27
|
+
* over the page, so the section stays a skeleton behind it rather than reading
|
|
28
|
+
* as empty.
|
|
29
|
+
*/
|
|
30
|
+
function SectionFailure({ title, error, onRetry, skeleton, }) {
|
|
31
|
+
if (isUnauthenticated(error))
|
|
32
|
+
return skeleton;
|
|
33
|
+
const message = formatErrorMessage(error);
|
|
34
|
+
return (_jsx(FailureBanner, { title: title, message: message, reportHref: spamReportHref(title, message), onRetry: onRetry }));
|
|
35
|
+
}
|
|
36
|
+
function OverviewSection() {
|
|
37
|
+
const [now] = useState(() => new Date());
|
|
38
|
+
const stats = useQuery({
|
|
39
|
+
...classificationStatsOperationsGetClassificationStatsOptions({
|
|
40
|
+
query: { since: spamOverviewSince(now) },
|
|
41
|
+
}),
|
|
42
|
+
meta: sectionMeta,
|
|
43
|
+
});
|
|
44
|
+
const skeleton = (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-4 w-64" }), _jsxs("div", { className: "grid gap-6 sm:grid-cols-2", children: [_jsx(Skeleton, { className: "h-32" }), _jsx(Skeleton, { className: "h-32" })] })] }));
|
|
45
|
+
if (stats.isPending)
|
|
46
|
+
return _jsx(Section, { title: "Last 30 days", children: skeleton });
|
|
47
|
+
if (stats.isError) {
|
|
48
|
+
return (_jsx(Section, { title: "Last 30 days", children: _jsx(SectionFailure, { title: "Couldn't count the last 30 days", error: stats.error, onRetry: () => void stats.refetch(), skeleton: skeleton }) }));
|
|
49
|
+
}
|
|
50
|
+
const overview = buildSpamOverview(stats.data, overviewDays(now));
|
|
51
|
+
if (!overview.checkedAny) {
|
|
52
|
+
return (_jsx(Section, { title: "Last 30 days", children: _jsxs("div", { className: "rounded-md border border-line px-4 py-6 text-center", children: [_jsx("p", { className: "font-medium text-fg", children: "Remit has not checked any mail yet" }), _jsx("p", { className: "mt-1 text-sm text-fg-muted", children: "Counts appear here once new mail arrives." })] }) }));
|
|
53
|
+
}
|
|
54
|
+
return (_jsxs(Section, { title: "Last 30 days", children: [_jsx("p", { className: "text-sm text-fg tabular-nums", children: `Reached Spam ${overview.moved} · Warned ${overview.warned}` }), _jsxs("div", { className: "grid gap-6 sm:grid-cols-2", children: [_jsx(SpamDailyChart, { title: "Spam", tone: "warning", days: overview.spam }), _jsx(SpamDailyChart, { title: "Phishing", tone: "danger", days: overview.phishing })] }), _jsxs("ul", { className: "flex list-none flex-wrap gap-x-4 gap-y-1 text-2xs text-fg-muted", children: [_jsxs("li", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "size-2 rounded-sm bg-fg-muted", "aria-hidden": "true" }), "Reached the Move to Spam threshold"] }), _jsxs("li", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "size-2 rounded-sm bg-fg-muted/35", "aria-hidden": "true" }), "Warned"] })] })] }));
|
|
55
|
+
}
|
|
56
|
+
const latestOf = async (labelId) => {
|
|
57
|
+
const { data } = await unifiedThreadOperationsListAllThreads({
|
|
58
|
+
query: { labelId, order: "desc", limit: LATEST_COUNT },
|
|
59
|
+
throwOnError: true,
|
|
60
|
+
});
|
|
61
|
+
return data.items ?? [];
|
|
62
|
+
};
|
|
63
|
+
function LatestSection() {
|
|
64
|
+
const junkMailboxIds = useJunkMailboxIds();
|
|
65
|
+
const config = useQuery({
|
|
66
|
+
...configOperationsGetConfigOptions(),
|
|
67
|
+
staleTime: Infinity,
|
|
68
|
+
});
|
|
69
|
+
const labelList = useLabelList(config.data?.accounts[0]?.accountId);
|
|
70
|
+
const spamLabel = labelList.labels.find((label) => label.name === "Spam");
|
|
71
|
+
const phishingLabel = labelList.labels.find((label) => label.name === "Phishing");
|
|
72
|
+
const labelIds = [spamLabel, phishingLabel].flatMap((label) => label ? [label.labelId] : []);
|
|
73
|
+
const latest = useQuery({
|
|
74
|
+
queryKey: ["spam-settings", "latest-flagged", ...labelIds],
|
|
75
|
+
queryFn: async () => (await Promise.all(labelIds.map(latestOf)))
|
|
76
|
+
.flat()
|
|
77
|
+
.filter((row) => !row.spamCleared && remitSpamLabel(row.labels) !== undefined)
|
|
78
|
+
.sort((a, b) => b.sentDate - a.sentDate)
|
|
79
|
+
.slice(0, LATEST_COUNT),
|
|
80
|
+
enabled: labelList.isSuccess,
|
|
81
|
+
meta: sectionMeta,
|
|
82
|
+
});
|
|
83
|
+
const skeleton = (_jsx("div", { className: "space-y-2", children: ["a", "b", "c", "d"].map((key) => (_jsx(Skeleton, { className: "h-10" }, key))) }));
|
|
84
|
+
const failure = config.isError
|
|
85
|
+
? { error: config.error, retry: () => void config.refetch() }
|
|
86
|
+
: labelList.isError
|
|
87
|
+
? { error: labelList.error, retry: () => void labelList.refetch() }
|
|
88
|
+
: latest.isError
|
|
89
|
+
? { error: latest.error, retry: () => void latest.refetch() }
|
|
90
|
+
: undefined;
|
|
91
|
+
if (failure) {
|
|
92
|
+
return (_jsx(Section, { title: "Latest flagged", children: _jsx(SectionFailure, { title: "Couldn't load the latest flagged mail", error: failure.error, onRetry: failure.retry, skeleton: skeleton }) }));
|
|
93
|
+
}
|
|
94
|
+
if (!latest.isSuccess) {
|
|
95
|
+
return _jsx(Section, { title: "Latest flagged", children: skeleton });
|
|
96
|
+
}
|
|
97
|
+
if (latest.data.length === 0) {
|
|
98
|
+
return (_jsx(Section, { title: "Latest flagged", children: _jsx("p", { className: "text-sm text-fg-muted", children: "Nothing flagged yet." }) }));
|
|
99
|
+
}
|
|
100
|
+
return (_jsx(Section, { title: "Latest flagged", aside: _jsxs("span", { className: "flex gap-4 text-sm", children: [spamLabel && (_jsx(NavLink, { to: "/mail/label/$labelId", params: { labelId: spamLabel.labelId }, variant: "inline", children: "Review all in Spam" })), phishingLabel && (_jsx(NavLink, { to: "/mail/label/$labelId", params: { labelId: phishingLabel.labelId }, variant: "inline", children: "Open Phishing" }))] }), children: _jsx("div", { className: "overflow-x-auto rounded-md border border-line", children: _jsxs("table", { className: "w-full text-left text-sm", children: [_jsx("thead", { className: "border-b border-line text-2xs uppercase tracking-wide text-fg-subtle", children: _jsxs("tr", { children: [_jsx("th", { className: "px-3 py-2 font-medium", children: "Sender" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Subject and top reason" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Date" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Label" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Action" })] }) }), _jsx("tbody", { className: "divide-y divide-line", children: latest.data.map((row) => {
|
|
101
|
+
const label = remitSpamLabel(row.labels);
|
|
102
|
+
if (!label)
|
|
103
|
+
return null;
|
|
104
|
+
const verdict = flaggedVerdict(row.spamVerdict);
|
|
105
|
+
return (_jsxs("tr", { className: "hover:bg-surface-sunken", children: [_jsx("td", { className: "px-3 py-2 align-top text-fg", children: row.fromName ?? row.fromEmail ?? "Unknown" }), _jsxs("td", { className: "px-3 py-2 align-top", children: [_jsx(NavLink, { to: "/mail/label/$labelId/$threadId/$messageId", params: {
|
|
106
|
+
labelId: label.labelId,
|
|
107
|
+
threadId: row.threadId,
|
|
108
|
+
messageId: row.messageId,
|
|
109
|
+
}, variant: "inline", className: "text-fg", children: row.subject ?? "(No subject)" }), verdict && (_jsx("p", { className: "text-xs text-fg-muted", children: topSpamReasonSentence(verdict.reasons) }))] }), _jsx("td", { className: "whitespace-nowrap px-3 py-2 align-top text-fg-muted tabular-nums", children: formatEmailDate(row.sentDate) }), _jsx("td", { className: "px-3 py-2 align-top", children: _jsx(LabelChip, { label: label }) }), _jsx("td", { className: "px-3 py-2 align-top text-fg-muted", children: junkMailboxIds.has(row.mailboxId) ? "Moved" : "Warned" })] }, row.messageId));
|
|
110
|
+
}) })] }) }) }));
|
|
111
|
+
}
|
|
112
|
+
function ThresholdsSection({ spam }) {
|
|
113
|
+
const { thresholds } = spam;
|
|
114
|
+
return (_jsxs(Section, { title: "Thresholds", children: [thresholds.state === "Set" ? (_jsxs("dl", { className: "flex flex-wrap gap-x-8 gap-y-2 text-sm", children: [_jsxs("div", { children: [_jsx("dt", { className: "text-fg-muted", children: "Warn from" }), _jsx("dd", { className: "font-medium text-fg tabular-nums", children: formatSpamScore(thresholds.cleanBelow) })] }), _jsxs("div", { children: [_jsx("dt", { className: "text-fg-muted", children: "Move to Spam from" }), _jsx("dd", { className: "font-medium text-fg tabular-nums", children: formatSpamScore(thresholds.spamAt) })] })] })) : (_jsx("p", { className: "text-sm text-fg", children: "The spam service applies its own thresholds." })), _jsx("p", { className: "text-xs text-fg-muted", children: "Scores run from 0 to 1. The deployment sets these values, and they apply to mail arriving from now on. Check again in any list updates older mail." })] }));
|
|
115
|
+
}
|
|
116
|
+
const PLACEMENT_OPTIONS = [
|
|
117
|
+
{ value: "WarnOnly", label: "Warn only" },
|
|
118
|
+
{ value: "MoveToSpam", label: "Move to Spam" },
|
|
119
|
+
];
|
|
120
|
+
function PlacementSection({ spam }) {
|
|
121
|
+
const save = useSaveClassification();
|
|
122
|
+
const [announcement, setAnnouncement] = useState("");
|
|
123
|
+
const ids = useId();
|
|
124
|
+
const rows = [
|
|
125
|
+
{
|
|
126
|
+
field: "spamPlacementSpam",
|
|
127
|
+
label: "Spam",
|
|
128
|
+
value: spam.spamPlacement,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
field: "spamPlacementPhishing",
|
|
132
|
+
label: "Phishing",
|
|
133
|
+
value: spam.phishingPlacement,
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
return (_jsxs(Section, { title: "Per label", children: [_jsx("div", { className: "space-y-2", children: rows.map((row) => (_jsxs("div", { className: "flex items-center gap-4", children: [_jsx("span", { className: "w-20 text-sm text-fg", children: row.label }), _jsx(SegmentedControl, { name: `${ids}-${row.field}`, "aria-label": `${row.label} label`, size: "sm", options: PLACEMENT_OPTIONS, value: row.value, onChange: (placement) => {
|
|
137
|
+
setAnnouncement("");
|
|
138
|
+
save.mutate({ body: { [row.field]: placement } }, { onSuccess: () => setAnnouncement("Saved") });
|
|
139
|
+
} })] }, row.field))) }), _jsx("p", { className: "text-xs text-fg-muted", children: "Warn only keeps the message where it arrived, under the warning banner." }), save.isError && (_jsx(FailureBanner, { title: "The label setting was not saved", message: formatErrorMessage(save.error), reportHref: spamReportHref("The label setting was not saved", formatErrorMessage(save.error)), onRetry: () => save.variables && save.mutate(save.variables) })), _jsx("p", { "aria-live": "polite", className: "text-xs text-positive", children: announcement })] }));
|
|
140
|
+
}
|
|
141
|
+
function SettingsSections() {
|
|
142
|
+
const settings = useQuery({
|
|
143
|
+
...userSettingsOperationsGetUserSettingsOptions(),
|
|
144
|
+
meta: sectionMeta,
|
|
145
|
+
});
|
|
146
|
+
const skeleton = (_jsxs(_Fragment, { children: [_jsx(Section, { title: "Thresholds", children: _jsx(Skeleton, { className: "h-11 w-64" }) }), _jsxs(Section, { title: "Per label", children: [_jsx(Skeleton, { className: "h-9 w-48" }), _jsx(Skeleton, { className: "h-9 w-48" })] })] }));
|
|
147
|
+
if (settings.isPending)
|
|
148
|
+
return skeleton;
|
|
149
|
+
if (settings.isError) {
|
|
150
|
+
return (_jsx(Section, { title: "Thresholds", children: _jsx(SectionFailure, { title: "Couldn't load the spam settings", error: settings.error, onRetry: () => void settings.refetch(), skeleton: skeleton }) }));
|
|
151
|
+
}
|
|
152
|
+
return (_jsxs(_Fragment, { children: [_jsx(ThresholdsSection, { spam: settings.data.spam }), _jsx(PlacementSection, { spam: settings.data.spam })] }));
|
|
153
|
+
}
|
|
154
|
+
function SendersSection() {
|
|
155
|
+
const groups = [
|
|
156
|
+
{
|
|
157
|
+
title: "Never in Spam",
|
|
158
|
+
hint: "Their mail skips the spam check.",
|
|
159
|
+
group: "neverSpam",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
title: "Reported",
|
|
163
|
+
hint: "Their mail goes straight to Spam.",
|
|
164
|
+
group: "blocked",
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
return (_jsx(Section, { title: "Senders", children: _jsx("ul", { className: "list-none divide-y divide-line rounded-md border border-line", children: groups.map((group) => (_jsxs("li", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [_jsxs("div", { children: [_jsx("p", { className: "text-sm font-medium text-fg", children: group.title }), _jsx("p", { className: "text-xs text-fg-muted", children: group.hint })] }), _jsx(NavLink, { to: "/settings/senders", search: { group: group.group }, variant: "inline", className: cn(buttonClassName({ variant: "secondary" }), "min-h-11 hover:no-underline"), "aria-label": `Manage ${group.title}`, children: "Manage" })] }, group.title))) }) }));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The Spam & phishing settings at `/settings/spam`: what Remit flagged in the
|
|
171
|
+
* last 30 days, the thresholds in effect, the per-label action and the sender
|
|
172
|
+
* groups. Every section loads and fails on its own.
|
|
173
|
+
*/
|
|
174
|
+
export function SpamSettingsPanel() {
|
|
175
|
+
return (_jsxs("div", { className: "max-w-3xl space-y-8", children: [_jsx(OverviewSection, {}), _jsx(LatestSection, {}), _jsx(SettingsSections, {}), _jsx(SendersSection, {})] }));
|
|
176
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RemitImapAddressResponse, RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IntelligenceData, PlacementIntel, SenderIntel } from "@remit/ui";
|
|
3
3
|
/**
|
|
4
4
|
* A sender address we cannot read: empty, missing the `@`, or whose domain
|
|
5
5
|
* part carries no dot (catches placeholders like `missing_domain` and other
|
|
@@ -25,8 +25,6 @@ export declare function buildCategoryIntel(thread: RemitImapThreadMessageRespons
|
|
|
25
25
|
* than rendering a misleading "0 received" next to an earned trust badge.
|
|
26
26
|
*/
|
|
27
27
|
export declare function buildSenderIntel(thread: RemitImapThreadMessageResponse, address: RemitImapAddressResponse | undefined): SenderIntel;
|
|
28
|
-
/** Build authenticity intel from the thread message's authenticity field. */
|
|
29
|
-
export declare function buildAuthenticityIntel(thread: RemitImapThreadMessageResponse): AuthenticityIntel;
|
|
30
28
|
export declare function buildPlacementIntel(thread: RemitImapThreadMessageResponse): PlacementIntel | undefined;
|
|
31
29
|
export interface UseIntelligenceDataResult {
|
|
32
30
|
data: Omit<IntelligenceData, "spamAction"> | null;
|
|
@@ -52,7 +50,7 @@ export interface UseIntelligenceDataResult {
|
|
|
52
50
|
* Maps a `RemitImapThreadMessageResponse` into `IntelligenceData` for the
|
|
53
51
|
* `IntelligencePanel` component. Two data sources:
|
|
54
52
|
*
|
|
55
|
-
* 1. The thread row itself (already loaded) → sender basics, trust,
|
|
53
|
+
* 1. The thread row itself (already loaded) → sender basics, trust, category.
|
|
56
54
|
* 2. `GET /addresses/search?q=<email>` → address flags (VIP/muted/blocked/etc.)
|
|
57
55
|
* and first-seen timestamp. One round-trip per unique sender.
|
|
58
56
|
*/
|