@remit/web-client 0.0.342 → 0.0.344
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/IntelligencePane.d.ts +7 -8
- package/dist/src/components/mail/IntelligencePane.js +48 -17
- package/dist/src/hooks/useIntelligenceData.d.ts +3 -2
- package/dist/src/hooks/useIntelligenceData.js +19 -1
- package/dist/src/hooks/useReportSpam.d.ts +17 -11
- package/dist/src/hooks/useReportSpam.js +53 -26
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
+
import { type SpamAction } from "@remit/ui";
|
|
2
3
|
import type { OpenThreadTarget } from "../../routing";
|
|
3
4
|
import type { ReplyWithText } from "../compose/reply-with-times";
|
|
4
5
|
export interface IntelligencePaneProps {
|
|
@@ -35,18 +36,16 @@ export interface IntelligencePaneProps {
|
|
|
35
36
|
onOpenThread?: (target: OpenThreadTarget) => void;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
|
-
* Decide which spam quick-action to offer for the current message
|
|
39
|
+
* Decide which spam quick-action to offer for the current message.
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* report offers the undo ("Not spam"); everything else offers "Report spam".
|
|
45
|
-
* Pure so the wiring decision can be unit-tested without rendering.
|
|
41
|
+
* A message that carries a spam report offers the undo (issue #648). An
|
|
42
|
+
* unreported message in Junk offers "Not spam", which moves the thread's Junk
|
|
43
|
+
* messages out and trusts the sender (reader#1553). Everything else offers
|
|
44
|
+
* "Report spam".
|
|
46
45
|
*/
|
|
47
46
|
export declare const resolveSpamAction: (thread: {
|
|
48
47
|
spamReport?: unknown;
|
|
49
|
-
}) =>
|
|
48
|
+
}, inJunk: boolean) => SpamAction;
|
|
50
49
|
/**
|
|
51
50
|
* Pane 4 of the 4-pane shell: the intelligence sidebar. Wired to real data via
|
|
52
51
|
* `useIntelligenceData`; renders the `IntelligencePanel` from `@remit/ui`.
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { threadDetailOperationsListThreadMessagesOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
3
|
import { CATEGORY_PRESENTATION, categoryLabels, DialogBackdrop, IntelligencePanel, useModalFocus, } from "@remit/ui";
|
|
4
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
3
5
|
import { Sparkles } from "lucide-react";
|
|
4
|
-
import { useCallback, useRef, useState } from "react";
|
|
6
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
7
|
+
import { useJunkMailbox } from "../../hooks/useArchiveMailbox";
|
|
5
8
|
import { useIntelligenceCalendar } from "../../hooks/useIntelligenceCalendar";
|
|
6
9
|
import { useIntelligenceData } from "../../hooks/useIntelligenceData";
|
|
7
10
|
import { useReportSpam } from "../../hooks/useReportSpam";
|
|
@@ -12,16 +15,20 @@ import { useTelemetry } from "../../lib/telemetry-context";
|
|
|
12
15
|
const isCategoryOverride = (category) => category !== "uncategorized";
|
|
13
16
|
const CATEGORY_OVERRIDES = CATEGORY_PRESENTATION.map((entry) => entry.category).filter(isCategoryOverride);
|
|
14
17
|
/**
|
|
15
|
-
* Decide which spam quick-action to offer for the current message
|
|
18
|
+
* Decide which spam quick-action to offer for the current message.
|
|
16
19
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* report offers the undo ("Not spam"); everything else offers "Report spam".
|
|
22
|
-
* Pure so the wiring decision can be unit-tested without rendering.
|
|
20
|
+
* A message that carries a spam report offers the undo (issue #648). An
|
|
21
|
+
* unreported message in Junk offers "Not spam", which moves the thread's Junk
|
|
22
|
+
* messages out and trusts the sender (reader#1553). Everything else offers
|
|
23
|
+
* "Report spam".
|
|
23
24
|
*/
|
|
24
|
-
export const resolveSpamAction = (thread) =>
|
|
25
|
+
export const resolveSpamAction = (thread, inJunk) => {
|
|
26
|
+
if (thread.spamReport)
|
|
27
|
+
return "undoSpamReport";
|
|
28
|
+
if (inJunk)
|
|
29
|
+
return "notSpam";
|
|
30
|
+
return "reportSpam";
|
|
31
|
+
};
|
|
25
32
|
function IntelligenceSkeleton() {
|
|
26
33
|
return (_jsxs("aside", { className: "flex h-full w-full flex-col bg-surface-sunken", children: [_jsxs("header", { className: "flex h-pane-header shrink-0 items-center gap-1.5 border-b border-line px-row-inset", children: [_jsx(Sparkles, { className: "size-3.5 text-fg-subtle" }), _jsx("span", { className: "text-2xs font-semibold uppercase tracking-wider text-fg-subtle", children: "Intelligence" })] }), _jsxs("div", { className: "flex-1 animate-pulse space-y-4 p-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "h-2.5 rounded bg-surface w-1/4" }), _jsxs("div", { className: "flex gap-3", children: [_jsx("div", { className: "size-10 rounded-full bg-surface shrink-0" }), _jsxs("div", { className: "flex-1 space-y-1.5", children: [_jsx("div", { className: "h-3 rounded bg-surface w-3/4" }), _jsx("div", { className: "h-2.5 rounded bg-surface w-1/2" })] })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "h-2.5 rounded bg-surface w-1/4" }), _jsx("div", { className: "h-8 rounded bg-surface" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "h-2.5 rounded bg-surface w-1/4" }), _jsx("div", { className: "flex gap-1.5 flex-wrap", children: Array.from({ length: 5 }).map((_, i) => (
|
|
27
34
|
// biome-ignore lint/suspicious/noArrayIndexKey: list is static, no stable id
|
|
@@ -47,7 +54,9 @@ function ReclassifyDialog({ isOpen, current, hasOverride, onSelect, onClear, onC
|
|
|
47
54
|
* Inner panel that resolves intelligence data and wires quick-action mutations.
|
|
48
55
|
*/
|
|
49
56
|
function WiredPanel({ thread, onClose, accountId, hideCloseButton, onAfterOptimisticRemove, onReplyWithText, onOpenThread, }) {
|
|
50
|
-
const { data, address, addressId } = useIntelligenceData(thread);
|
|
57
|
+
const { data: threadData, address, addressId } = useIntelligenceData(thread);
|
|
58
|
+
const { junkMailboxId } = useJunkMailbox(accountId);
|
|
59
|
+
const queryClient = useQueryClient();
|
|
51
60
|
const calendar = useIntelligenceCalendar(thread, onReplyWithText, onOpenThread);
|
|
52
61
|
const [reclassifyOpen, setReclassifyOpen] = useState(false);
|
|
53
62
|
const senderEmail = thread.fromEmail ?? undefined;
|
|
@@ -55,19 +64,41 @@ function WiredPanel({ thread, onClose, accountId, hideCloseButton, onAfterOptimi
|
|
|
55
64
|
addressId,
|
|
56
65
|
senderEmail,
|
|
57
66
|
});
|
|
58
|
-
|
|
59
|
-
// message carries a spam report — never by the mailbox it's in (issue #648).
|
|
60
|
-
const { reportSpam, notSpam, isReporting, isRestoring } = useReportSpam({
|
|
67
|
+
const { reportSpam, notSpam, moveOutOfSpam, isReporting, isRestoring } = useReportSpam({
|
|
61
68
|
mailboxId: thread.mailboxId,
|
|
62
69
|
threadId: thread.threadId,
|
|
63
70
|
accountId,
|
|
64
71
|
onAfterOptimisticRemove,
|
|
65
72
|
});
|
|
66
73
|
const telemetry = useTelemetry();
|
|
67
|
-
const spamAction = resolveSpamAction(thread);
|
|
74
|
+
const spamAction = resolveSpamAction(thread, junkMailboxId !== undefined && thread.mailboxId === junkMailboxId);
|
|
75
|
+
const data = useMemo(() => (threadData ? { ...threadData, spamAction } : null), [threadData, spamAction]);
|
|
68
76
|
const handleNotSpam = useCallback(() => {
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
if (spamAction === "undoSpamReport") {
|
|
78
|
+
notSpam([thread.messageId]);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
void queryClient
|
|
82
|
+
.ensureQueryData(threadDetailOperationsListThreadMessagesOptions({
|
|
83
|
+
path: { threadId: thread.threadId },
|
|
84
|
+
}))
|
|
85
|
+
.then(({ items }) => {
|
|
86
|
+
const ids = new Set([thread.messageId]);
|
|
87
|
+
for (const message of items) {
|
|
88
|
+
if (message.mailboxId === junkMailboxId)
|
|
89
|
+
ids.add(message.messageId);
|
|
90
|
+
}
|
|
91
|
+
moveOutOfSpam([...ids]);
|
|
92
|
+
});
|
|
93
|
+
}, [
|
|
94
|
+
notSpam,
|
|
95
|
+
moveOutOfSpam,
|
|
96
|
+
queryClient,
|
|
97
|
+
spamAction,
|
|
98
|
+
thread.messageId,
|
|
99
|
+
thread.threadId,
|
|
100
|
+
junkMailboxId,
|
|
101
|
+
]);
|
|
71
102
|
const handleReportSpam = useCallback(() => {
|
|
72
103
|
recordRescueSentToJunk(telemetry, {
|
|
73
104
|
count: 1,
|
|
@@ -101,7 +132,7 @@ function WiredPanel({ thread, onClose, accountId, hideCloseButton, onAfterOptimi
|
|
|
101
132
|
onToggleVip: canUpdateFlags ? handleToggleVip : undefined,
|
|
102
133
|
onToggleMute: canUpdateFlags ? handleToggleMute : undefined,
|
|
103
134
|
onReclassify: canUpdateFlags ? () => setReclassifyOpen(true) : undefined,
|
|
104
|
-
onNotSpam: spamAction === "
|
|
135
|
+
onNotSpam: spamAction === "reportSpam" ? undefined : handleNotSpam,
|
|
105
136
|
onReportSpam: spamAction === "reportSpam" ? handleReportSpam : undefined,
|
|
106
137
|
};
|
|
107
138
|
if (!data) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RemitImapAddressResponse, RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
-
import type { AuthenticityIntel, IntelligenceData, SenderIntel } from "@remit/ui";
|
|
2
|
+
import type { AuthenticityIntel, 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
|
|
@@ -27,8 +27,9 @@ export declare function buildCategoryIntel(thread: RemitImapThreadMessageRespons
|
|
|
27
27
|
export declare function buildSenderIntel(thread: RemitImapThreadMessageResponse, address: RemitImapAddressResponse | undefined): SenderIntel;
|
|
28
28
|
/** Build authenticity intel from the thread message's authenticity field. */
|
|
29
29
|
export declare function buildAuthenticityIntel(thread: RemitImapThreadMessageResponse): AuthenticityIntel;
|
|
30
|
+
export declare function buildPlacementIntel(thread: RemitImapThreadMessageResponse): PlacementIntel | undefined;
|
|
30
31
|
export interface UseIntelligenceDataResult {
|
|
31
|
-
data: IntelligenceData | null;
|
|
32
|
+
data: Omit<IntelligenceData, "spamAction"> | null;
|
|
32
33
|
/**
|
|
33
34
|
* True when the address lookup failed with a fatal first-party 5xx. The panel
|
|
34
35
|
* must not silently render the sender's flags (VIP/muted/blocked) as absent —
|
|
@@ -206,6 +206,18 @@ export function buildAuthenticityIntel(thread) {
|
|
|
206
206
|
summary,
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
+
export function buildPlacementIntel(thread) {
|
|
210
|
+
const verdict = thread.placementVerdict;
|
|
211
|
+
if (!verdict)
|
|
212
|
+
return undefined;
|
|
213
|
+
return {
|
|
214
|
+
action: verdict.action,
|
|
215
|
+
confidence: verdict.confidence,
|
|
216
|
+
fromPlacement: verdict.fromPlacement,
|
|
217
|
+
reasons: verdict.reasons,
|
|
218
|
+
dryRun: verdict.dryRun,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
209
221
|
/**
|
|
210
222
|
* Maps a `RemitImapThreadMessageResponse` into `IntelligenceData` for the
|
|
211
223
|
* `IntelligencePanel` component. Two data sources:
|
|
@@ -232,7 +244,13 @@ export function useIntelligenceData(thread) {
|
|
|
232
244
|
const authenticity = buildAuthenticityIntel(thread);
|
|
233
245
|
const category = buildCategoryIntel(thread, address);
|
|
234
246
|
const flags = buildSenderFlags(address);
|
|
235
|
-
return {
|
|
247
|
+
return {
|
|
248
|
+
sender,
|
|
249
|
+
authenticity,
|
|
250
|
+
category,
|
|
251
|
+
flags,
|
|
252
|
+
placement: buildPlacementIntel(thread),
|
|
253
|
+
};
|
|
236
254
|
}, [thread, address]);
|
|
237
255
|
return {
|
|
238
256
|
data,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RemitImapSpamReportBulkResult } from "@remit/api-http-client/types.gen.ts";
|
|
2
|
+
import { ApiError } from "../lib/api";
|
|
2
3
|
interface UseReportSpamOptions {
|
|
3
4
|
/** The mailbox the message currently sits in — scopes which list caches settle-time invalidation reaches. */
|
|
4
5
|
mailboxId: string;
|
|
@@ -52,9 +53,9 @@ export declare const humanizeSpamFailureReason: (reason: string, messageId: stri
|
|
|
52
53
|
* call — a partial (or total) failure is not a thrown error on the wire. The
|
|
53
54
|
* generated mutation helpers only ever reject on a non-2xx response, so
|
|
54
55
|
* without this the hook would report success for a message whose report or
|
|
55
|
-
* undo never actually happened.
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* undo never actually happened. The thrown error carries the batch's
|
|
57
|
+
* `failureCount` for the banner title and the first failure's reason as its
|
|
58
|
+
* message.
|
|
58
59
|
*
|
|
59
60
|
* Throws `ApiError` — not a bare `Error` — carrying a 4xx status. The
|
|
60
61
|
* client's fail-fast contract (`lib/error-classifier.ts`'s `shouldEscalate`,
|
|
@@ -70,15 +71,18 @@ export declare const humanizeSpamFailureReason: (reason: string, messageId: stri
|
|
|
70
71
|
* like this one; this is the one place synthesizing a failure from a 200
|
|
71
72
|
* body, so it has to synthesize both.
|
|
72
73
|
*/
|
|
74
|
+
export declare class SpamBulkFailureError extends ApiError {
|
|
75
|
+
readonly failureCount: number;
|
|
76
|
+
constructor(message: string, failureCount: number);
|
|
77
|
+
}
|
|
73
78
|
export declare const throwOnBulkFailure: (data: RemitImapSpamReportBulkResult) => void;
|
|
74
79
|
/**
|
|
75
|
-
* Composes `POST /messages/report-spam` and `POST /messages/not-spam
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* provider's own filter put it there — is a real, no-op-move case).
|
|
80
|
+
* Composes `POST /messages/report-spam` and `POST /messages/not-spam`. Both
|
|
81
|
+
* fold the sender-flag write, the mailbox move and the `$Junk` keyword marker
|
|
82
|
+
* into one server-side operation (`SpamReportService`); the client only sends
|
|
83
|
+
* `messageIds` and reflects the result. `notSpam` undoes a spam report;
|
|
84
|
+
* `moveOutOfSpam` sends the same request for unreported Junk messages and
|
|
85
|
+
* differs only in its failure copy.
|
|
82
86
|
*
|
|
83
87
|
* No optimistic cache patch, unlike `useMoveMessages`/`useDeleteMessages`:
|
|
84
88
|
* neither endpoint's response says whether the message actually changed
|
|
@@ -86,7 +90,8 @@ export declare const throwOnBulkFailure: (data: RemitImapSpamReportBulkResult) =
|
|
|
86
90
|
* silent no-op), so predicting the row should vanish would flicker it back
|
|
87
91
|
* on invalidation for a no-op — worst on `notSpam`, whose R2 wait can run
|
|
88
92
|
* several seconds before the row "pops back". The list settles from
|
|
89
|
-
* `
|
|
93
|
+
* `onSettled`'s invalidation instead, which also runs on a partial failure so
|
|
94
|
+
* the messages that did move leave the list. `isReporting`/
|
|
90
95
|
* `isRestoring` below exist to pay for the UX this trades away: without them
|
|
91
96
|
* a press produces no visible change at all until the request lands — the
|
|
92
97
|
* caller wires them into the quick action's pending state.
|
|
@@ -94,6 +99,7 @@ export declare const throwOnBulkFailure: (data: RemitImapSpamReportBulkResult) =
|
|
|
94
99
|
export declare function useReportSpam({ mailboxId, threadId, accountId, onAfterOptimisticRemove, }: UseReportSpamOptions): {
|
|
95
100
|
reportSpam: (messageIds: string[]) => void;
|
|
96
101
|
notSpam: (messageIds: string[]) => void;
|
|
102
|
+
moveOutOfSpam: (messageIds: string[]) => void;
|
|
97
103
|
/** True while a report is in flight — wire into the "Report spam" quick action's pending state; a press with no visible response is the dead-button failure mode. */
|
|
98
104
|
isReporting: boolean;
|
|
99
105
|
/** True while an undo is in flight — wire into the "Not spam" quick action's pending state. */
|
|
@@ -38,9 +38,9 @@ export const humanizeSpamFailureReason = (reason, messageId) => reason.replace(`
|
|
|
38
38
|
* call — a partial (or total) failure is not a thrown error on the wire. The
|
|
39
39
|
* generated mutation helpers only ever reject on a non-2xx response, so
|
|
40
40
|
* without this the hook would report success for a message whose report or
|
|
41
|
-
* undo never actually happened.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* undo never actually happened. The thrown error carries the batch's
|
|
42
|
+
* `failureCount` for the banner title and the first failure's reason as its
|
|
43
|
+
* message.
|
|
44
44
|
*
|
|
45
45
|
* Throws `ApiError` — not a bare `Error` — carrying a 4xx status. The
|
|
46
46
|
* client's fail-fast contract (`lib/error-classifier.ts`'s `shouldEscalate`,
|
|
@@ -56,6 +56,13 @@ export const humanizeSpamFailureReason = (reason, messageId) => reason.replace(`
|
|
|
56
56
|
* like this one; this is the one place synthesizing a failure from a 200
|
|
57
57
|
* body, so it has to synthesize both.
|
|
58
58
|
*/
|
|
59
|
+
export class SpamBulkFailureError extends ApiError {
|
|
60
|
+
failureCount;
|
|
61
|
+
constructor(message, failureCount) {
|
|
62
|
+
super(message, 422);
|
|
63
|
+
this.failureCount = failureCount;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
59
66
|
export const throwOnBulkFailure = (data) => {
|
|
60
67
|
if (data.failureCount === 0)
|
|
61
68
|
return;
|
|
@@ -64,16 +71,15 @@ export const throwOnBulkFailure = (data) => {
|
|
|
64
71
|
const message = failure
|
|
65
72
|
? humanizeSpamFailureReason(reason, failure.messageId)
|
|
66
73
|
: reason;
|
|
67
|
-
throw new
|
|
74
|
+
throw new SpamBulkFailureError(message, data.failureCount);
|
|
68
75
|
};
|
|
69
76
|
/**
|
|
70
|
-
* Composes `POST /messages/report-spam` and `POST /messages/not-spam
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* provider's own filter put it there — is a real, no-op-move case).
|
|
77
|
+
* Composes `POST /messages/report-spam` and `POST /messages/not-spam`. Both
|
|
78
|
+
* fold the sender-flag write, the mailbox move and the `$Junk` keyword marker
|
|
79
|
+
* into one server-side operation (`SpamReportService`); the client only sends
|
|
80
|
+
* `messageIds` and reflects the result. `notSpam` undoes a spam report;
|
|
81
|
+
* `moveOutOfSpam` sends the same request for unreported Junk messages and
|
|
82
|
+
* differs only in its failure copy.
|
|
77
83
|
*
|
|
78
84
|
* No optimistic cache patch, unlike `useMoveMessages`/`useDeleteMessages`:
|
|
79
85
|
* neither endpoint's response says whether the message actually changed
|
|
@@ -81,7 +87,8 @@ export const throwOnBulkFailure = (data) => {
|
|
|
81
87
|
* silent no-op), so predicting the row should vanish would flicker it back
|
|
82
88
|
* on invalidation for a no-op — worst on `notSpam`, whose R2 wait can run
|
|
83
89
|
* several seconds before the row "pops back". The list settles from
|
|
84
|
-
* `
|
|
90
|
+
* `onSettled`'s invalidation instead, which also runs on a partial failure so
|
|
91
|
+
* the messages that did move leave the list. `isReporting`/
|
|
85
92
|
* `isRestoring` below exist to pay for the UX this trades away: without them
|
|
86
93
|
* a press produces no visible change at all until the request lands — the
|
|
87
94
|
* caller wires them into the quick action's pending state.
|
|
@@ -106,17 +113,27 @@ export function useReportSpam({ mailboxId, threadId, accountId, onAfterOptimisti
|
|
|
106
113
|
});
|
|
107
114
|
}
|
|
108
115
|
};
|
|
109
|
-
const
|
|
110
|
-
invalidateAffectedQueries();
|
|
116
|
+
const onSuccess = (_data, variables) => {
|
|
111
117
|
onAfterOptimisticRemove?.(variables.body.messageIds);
|
|
112
118
|
};
|
|
113
119
|
const buildOnError = (failureTitle) => (err, vars) => {
|
|
120
|
+
const count = err instanceof SpamBulkFailureError
|
|
121
|
+
? err.failureCount
|
|
122
|
+
: vars.body.messageIds.length;
|
|
114
123
|
pushError({
|
|
115
|
-
title: failureTitle(
|
|
124
|
+
title: failureTitle(count),
|
|
116
125
|
detail: formatErrorDetail(err),
|
|
117
126
|
error: err,
|
|
118
127
|
});
|
|
119
128
|
};
|
|
129
|
+
const sendNotSpam = async (variables) => {
|
|
130
|
+
const { data } = await messageBulkOperationsNotSpam({
|
|
131
|
+
...variables,
|
|
132
|
+
throwOnError: true,
|
|
133
|
+
});
|
|
134
|
+
throwOnBulkFailure(data);
|
|
135
|
+
return data;
|
|
136
|
+
};
|
|
120
137
|
const report = useMutation({
|
|
121
138
|
mutationFn: async (variables) => {
|
|
122
139
|
const { data } = await messageBulkOperationsReportSpam({
|
|
@@ -132,26 +149,30 @@ export function useReportSpam({ mailboxId, threadId, accountId, onAfterOptimisti
|
|
|
132
149
|
// isn't enough: `shouldEscalate` defaults to escalate for a non-5xx that
|
|
133
150
|
// doesn't opt out here.
|
|
134
151
|
meta: { softError: true },
|
|
135
|
-
onSuccess
|
|
152
|
+
onSuccess,
|
|
153
|
+
onSettled: invalidateAffectedQueries,
|
|
136
154
|
onError: buildOnError((count) => count > 1
|
|
137
155
|
? `Couldn't report ${count} messages as spam`
|
|
138
156
|
: "Couldn't report this message as spam"),
|
|
139
157
|
});
|
|
140
158
|
const restore = useMutation({
|
|
141
|
-
mutationFn:
|
|
142
|
-
const { data } = await messageBulkOperationsNotSpam({
|
|
143
|
-
...variables,
|
|
144
|
-
throwOnError: true,
|
|
145
|
-
});
|
|
146
|
-
throwOnBulkFailure(data);
|
|
147
|
-
return data;
|
|
148
|
-
},
|
|
159
|
+
mutationFn: sendNotSpam,
|
|
149
160
|
meta: { softError: true },
|
|
150
|
-
onSuccess
|
|
161
|
+
onSuccess,
|
|
162
|
+
onSettled: invalidateAffectedQueries,
|
|
151
163
|
onError: buildOnError((count) => count > 1
|
|
152
164
|
? `Couldn't undo the spam report for ${count} messages`
|
|
153
165
|
: "Couldn't undo the spam report"),
|
|
154
166
|
});
|
|
167
|
+
const moveOut = useMutation({
|
|
168
|
+
mutationFn: sendNotSpam,
|
|
169
|
+
meta: { softError: true },
|
|
170
|
+
onSuccess,
|
|
171
|
+
onSettled: invalidateAffectedQueries,
|
|
172
|
+
onError: buildOnError((count) => count > 1
|
|
173
|
+
? `Couldn't move ${count} messages out of Spam`
|
|
174
|
+
: "Couldn't move this message out of Spam"),
|
|
175
|
+
});
|
|
155
176
|
const reportSpam = useCallback((messageIds) => {
|
|
156
177
|
if (messageIds.length === 0)
|
|
157
178
|
return;
|
|
@@ -162,12 +183,18 @@ export function useReportSpam({ mailboxId, threadId, accountId, onAfterOptimisti
|
|
|
162
183
|
return;
|
|
163
184
|
void runChunkedMutation(messageIds, (chunk) => restore.mutateAsync({ body: { messageIds: chunk } }));
|
|
164
185
|
}, [restore.mutateAsync]);
|
|
186
|
+
const moveOutOfSpam = useCallback((messageIds) => {
|
|
187
|
+
if (messageIds.length === 0)
|
|
188
|
+
return;
|
|
189
|
+
void runChunkedMutation(messageIds, (chunk) => moveOut.mutateAsync({ body: { messageIds: chunk } }));
|
|
190
|
+
}, [moveOut.mutateAsync]);
|
|
165
191
|
return {
|
|
166
192
|
reportSpam,
|
|
167
193
|
notSpam,
|
|
194
|
+
moveOutOfSpam,
|
|
168
195
|
/** True while a report is in flight — wire into the "Report spam" quick action's pending state; a press with no visible response is the dead-button failure mode. */
|
|
169
196
|
isReporting: report.isPending,
|
|
170
197
|
/** True while an undo is in flight — wire into the "Not spam" quick action's pending state. */
|
|
171
|
-
isRestoring: restore.isPending,
|
|
198
|
+
isRestoring: restore.isPending || moveOut.isPending,
|
|
172
199
|
};
|
|
173
200
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.344",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Remit web client, published as composable primitives — the app shell, auth shells, and runtime config. A distributor imports what it composes and bundles it.",
|
|
6
6
|
"exports": {
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@hookform/resolvers": "5.4.0",
|
|
94
|
-
"@remit/ui": "0.0.
|
|
94
|
+
"@remit/ui": "0.0.235",
|
|
95
95
|
"@tanstack/react-query": "5.101.2",
|
|
96
96
|
"@tanstack/react-query-devtools": "5.101.2",
|
|
97
97
|
"@tanstack/react-router": "1.170.18",
|