@remit/web-client 0.0.350 → 0.0.352
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/harness/index.html +1 -1
- package/dist/src/components/mail/MailSidebarAdapter.js +11 -2
- package/dist/src/hooks/calendar/useCalendarSuggestions.js +7 -5
- package/dist/src/hooks/useDeleteFolder.js +13 -26
- package/dist/src/hooks/useLabels.js +6 -5
- package/dist/src/hooks/useRescueCandidates.js +9 -5
- package/dist/src/lib/auto-moved.js +8 -7
- package/dist/src/lib/folder-failure.d.ts +1 -0
- package/dist/src/lib/folder-failure.js +3 -0
- package/dist/src/lib/list-pages.d.ts +13 -0
- package/dist/src/lib/list-pages.js +17 -0
- package/dist/src/routes/settings/senders.d.ts +1 -2
- package/dist/src/routes/settings/senders.js +28 -30
- package/package.json +2 -2
package/dist/harness/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Installability. The preset serves this page for every host. The two theme colours are the light and dark --canvas tokens from
|
|
9
9
|
packages/ui/src/tokens.css.
|
|
10
10
|
-->
|
|
11
|
-
<link rel="manifest" href="/manifest.webmanifest" />
|
|
11
|
+
<link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials" />
|
|
12
12
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
13
13
|
<link rel="icon" href="/favicon.ico" sizes="16x16 32x32" />
|
|
14
14
|
<link rel="icon" href="/icons/icon-192.png" type="image/png" sizes="192x192" />
|
|
@@ -6,7 +6,7 @@ import { useCallback, useMemo } from "react";
|
|
|
6
6
|
import { useTranslation } from "react-i18next";
|
|
7
7
|
import { useLabelUnreadCounts } from "../../hooks/useCollectionThreads";
|
|
8
8
|
import { useLabelList } from "../../hooks/useLabels";
|
|
9
|
-
import { folderFailure } from "../../lib/folder-failure";
|
|
9
|
+
import { folderFailure, folderUnavailable } from "../../lib/folder-failure";
|
|
10
10
|
import { buildMailboxRoleMap, labelForMailbox, shouldShowUnreadBadgeForRole, } from "../../lib/folder-roles";
|
|
11
11
|
import { withoutLabelFolders } from "../../lib/label-folders";
|
|
12
12
|
import { useMailContext } from "../../lib/mail-context";
|
|
@@ -44,6 +44,15 @@ function sortMailboxes(mailboxes, roleMap, t) {
|
|
|
44
44
|
labels.sort((a, b) => compareLabelNames(labelForMailbox(a, undefined, t), labelForMailbox(b, undefined, t)));
|
|
45
45
|
return { system, labels };
|
|
46
46
|
}
|
|
47
|
+
const folderNote = (mb) => {
|
|
48
|
+
const unavailable = folderUnavailable(mb);
|
|
49
|
+
if (unavailable)
|
|
50
|
+
return { kind: "unavailable", text: unavailable };
|
|
51
|
+
const failure = folderFailure(mb);
|
|
52
|
+
if (failure)
|
|
53
|
+
return { kind: "failure", text: failure };
|
|
54
|
+
return undefined;
|
|
55
|
+
};
|
|
47
56
|
/**
|
|
48
57
|
* Convert an API mailbox to a NavMailbox for the kit: `role` comes from the
|
|
49
58
|
* account's folder-role map (RFC 032 exclusive-folder-appointment, #976), the
|
|
@@ -58,7 +67,7 @@ function toNavMailbox(mb, role, t) {
|
|
|
58
67
|
unseen: showBadge ? mb.unseenCount : undefined,
|
|
59
68
|
role,
|
|
60
69
|
fullPath: mb.fullPath,
|
|
61
|
-
|
|
70
|
+
note: folderNote(mb),
|
|
62
71
|
};
|
|
63
72
|
}
|
|
64
73
|
function toNavLabels(labels, unreadByLabel) {
|
|
@@ -17,6 +17,7 @@ import { formatErrorMessage } from "@remit/ui";
|
|
|
17
17
|
import { useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
|
|
18
18
|
import { useCallback, useMemo } from "react";
|
|
19
19
|
import { softErrorStatuses } from "../../lib/error-classifier";
|
|
20
|
+
import { listPages } from "../../lib/list-pages";
|
|
20
21
|
const SUGGESTION_META = softErrorStatuses(400, 404);
|
|
21
22
|
/** Every read an answer can change: the cards, the calendar, the sender rules. */
|
|
22
23
|
const ANSWERED_QUERY_IDS = new Set([
|
|
@@ -63,18 +64,19 @@ export function usePendingCalendarSuggestions() {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
const findPending = async (suggestionId, signal) => {
|
|
66
|
-
|
|
67
|
-
do {
|
|
67
|
+
const pages = listPages(async (continuationToken) => {
|
|
68
68
|
const { data } = await calendarSuggestionOperationsListCalendarSuggestions({
|
|
69
69
|
query: { state: "Pending", continuationToken },
|
|
70
70
|
signal,
|
|
71
71
|
throwOnError: true,
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
return data;
|
|
74
|
+
});
|
|
75
|
+
for await (const items of pages) {
|
|
76
|
+
const found = items.find((item) => item.suggestionId === suggestionId);
|
|
74
77
|
if (found)
|
|
75
78
|
return found;
|
|
76
|
-
|
|
77
|
-
} while (continuationToken);
|
|
79
|
+
}
|
|
78
80
|
return null;
|
|
79
81
|
};
|
|
80
82
|
export function usePendingCalendarSuggestion(suggestionId) {
|
|
@@ -4,7 +4,16 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
|
4
4
|
import { useCallback, useRef, useState } from "react";
|
|
5
5
|
import { advanceMove, beginMove, failMove, MOVE_BATCH_SIZE, } from "../lib/delete-folder";
|
|
6
6
|
import { awaitFreshMailboxCount, mailboxSyncStamp, } from "../lib/fresh-mailbox-count";
|
|
7
|
+
import { listPages } from "../lib/list-pages";
|
|
7
8
|
const PAGE_CAP = 50;
|
|
9
|
+
const threadPages = (mailboxId, signal) => listPages(async (continuationToken) => {
|
|
10
|
+
const { data } = await threadOperationsListThreads({
|
|
11
|
+
path: { mailboxId },
|
|
12
|
+
query: { order: "desc", continuationToken },
|
|
13
|
+
throwOnError: true,
|
|
14
|
+
});
|
|
15
|
+
return data;
|
|
16
|
+
}, { maxPages: PAGE_CAP, signal });
|
|
8
17
|
const errorText = (error) => error instanceof Error ? error.message : "Something went wrong.";
|
|
9
18
|
/**
|
|
10
19
|
* Run a network call to a branchable result instead of a thrown exception, so
|
|
@@ -20,16 +29,8 @@ const attempt = (work) => work.then((value) => ({ ok: true, value }), (error) =>
|
|
|
20
29
|
*/
|
|
21
30
|
const collectMovableIds = async (mailboxId, alreadyMoved, limit, signal) => {
|
|
22
31
|
const ids = [];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (signal.aborted)
|
|
26
|
-
return ids;
|
|
27
|
-
const { data } = await threadOperationsListThreads({
|
|
28
|
-
path: { mailboxId },
|
|
29
|
-
query: { order: "desc", continuationToken },
|
|
30
|
-
throwOnError: true,
|
|
31
|
-
});
|
|
32
|
-
for (const item of data.items) {
|
|
32
|
+
for await (const items of threadPages(mailboxId, signal)) {
|
|
33
|
+
for (const item of items) {
|
|
33
34
|
if (alreadyMoved.has(item.messageId))
|
|
34
35
|
continue;
|
|
35
36
|
if (ids.includes(item.messageId))
|
|
@@ -38,9 +39,6 @@ const collectMovableIds = async (mailboxId, alreadyMoved, limit, signal) => {
|
|
|
38
39
|
if (ids.length >= limit)
|
|
39
40
|
return ids;
|
|
40
41
|
}
|
|
41
|
-
if (!data.continuationToken)
|
|
42
|
-
break;
|
|
43
|
-
continuationToken = data.continuationToken;
|
|
44
42
|
}
|
|
45
43
|
return ids;
|
|
46
44
|
};
|
|
@@ -52,19 +50,8 @@ const collectMovableIds = async (mailboxId, alreadyMoved, limit, signal) => {
|
|
|
52
50
|
*/
|
|
53
51
|
const liveMessageCount = async (mailboxId, signal) => {
|
|
54
52
|
let count = 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (signal.aborted)
|
|
58
|
-
return count;
|
|
59
|
-
const { data } = await threadOperationsListThreads({
|
|
60
|
-
path: { mailboxId },
|
|
61
|
-
query: { order: "desc", continuationToken },
|
|
62
|
-
throwOnError: true,
|
|
63
|
-
});
|
|
64
|
-
count += data.items.length;
|
|
65
|
-
if (!data.continuationToken)
|
|
66
|
-
break;
|
|
67
|
-
continuationToken = data.continuationToken;
|
|
53
|
+
for await (const items of threadPages(mailboxId, signal)) {
|
|
54
|
+
count += items.length;
|
|
68
55
|
}
|
|
69
56
|
return count;
|
|
70
57
|
};
|
|
@@ -2,6 +2,7 @@ import { labelDetailOperationsDeleteLabelMutation, labelDetailOperationsUpdateLa
|
|
|
2
2
|
import { labelOperationsListLabels } from "@remit/api-http-client/sdk.gen.ts";
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
|
+
import { listPages } from "../lib/list-pages";
|
|
5
6
|
/**
|
|
6
7
|
* The query key the label list reads and every mutation invalidates on
|
|
7
8
|
* success — the same contract `buildFilterListKey` pins for filters, so the
|
|
@@ -11,16 +12,16 @@ import { useCallback } from "react";
|
|
|
11
12
|
export const buildLabelListKey = (accountId) => labelOperationsListLabelsQueryKey({ path: { accountId } });
|
|
12
13
|
const listAllLabels = async (accountId) => {
|
|
13
14
|
const labels = [];
|
|
14
|
-
|
|
15
|
-
do {
|
|
15
|
+
const pages = listPages(async (continuationToken) => {
|
|
16
16
|
const { data } = await labelOperationsListLabels({
|
|
17
17
|
path: { accountId },
|
|
18
18
|
query: { continuationToken },
|
|
19
19
|
throwOnError: true,
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return data;
|
|
22
|
+
});
|
|
23
|
+
for await (const items of pages)
|
|
24
|
+
labels.push(...items);
|
|
24
25
|
return labels;
|
|
25
26
|
};
|
|
26
27
|
const NO_LABELS = [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { threadOperationsSearchThreadsQueryKey } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
2
|
import { threadOperationsSearchThreads } from "@remit/api-http-client/sdk.gen.ts";
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { listPages } from "../lib/list-pages";
|
|
4
5
|
import { rescueCandidateReason } from "../lib/rescue-candidates";
|
|
5
6
|
const TRUST_REASON = "We can verify this sender";
|
|
6
7
|
/**
|
|
@@ -29,16 +30,19 @@ export function useRescueCandidates(junkMailboxId) {
|
|
|
29
30
|
queryKey: threadOperationsSearchThreadsQueryKey({ path, query }),
|
|
30
31
|
queryFn: async () => {
|
|
31
32
|
const items = [];
|
|
32
|
-
|
|
33
|
-
do {
|
|
33
|
+
const pages = listPages(async (continuationToken) => {
|
|
34
34
|
const { data: page } = await threadOperationsSearchThreads({
|
|
35
35
|
path,
|
|
36
36
|
query: { ...query, continuationToken },
|
|
37
37
|
throwOnError: true,
|
|
38
38
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return {
|
|
40
|
+
items: page.items ?? [],
|
|
41
|
+
continuationToken: page.continuationToken,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
for await (const page of pages)
|
|
45
|
+
items.push(...page);
|
|
42
46
|
return { items };
|
|
43
47
|
},
|
|
44
48
|
enabled: !!junkMailboxId,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { PlacementAction } from "@remit/domain-enums";
|
|
1
|
+
import { FromPlacement, PlacementAction } from "@remit/domain-enums";
|
|
2
2
|
const FROM_PLACEMENT_LABEL = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
[FromPlacement.Inbox]: "Inbox",
|
|
4
|
+
[FromPlacement.Junk]: "Junk",
|
|
5
|
+
[FromPlacement.Other]: "another folder",
|
|
5
6
|
};
|
|
6
7
|
/** A standing-filter move names an arbitrary destination via `destinationMailboxId`; a classifier move names a direction via `action`. */
|
|
7
8
|
const isFilterMove = (autoMoved) => autoMoved.destinationMailboxId !== undefined;
|
|
@@ -19,8 +20,8 @@ export const autoMovedLabel = (autoMoved, sourceFolderName) => {
|
|
|
19
20
|
if (isFilterMove(autoMoved)) {
|
|
20
21
|
return `Moved from ${sourceFolderName ?? "another folder"} by Remit`;
|
|
21
22
|
}
|
|
22
|
-
const from = autoMoved.fromPlacement ??
|
|
23
|
-
return `Moved from ${FROM_PLACEMENT_LABEL[from]
|
|
23
|
+
const from = autoMoved.fromPlacement ?? FromPlacement.Other;
|
|
24
|
+
return `Moved from ${FROM_PLACEMENT_LABEL[from]} by Remit`;
|
|
24
25
|
};
|
|
25
26
|
/**
|
|
26
27
|
* The mailbox the verdict's `action` implies as the destination — where a
|
|
@@ -74,9 +75,9 @@ export const resolveUndoTargetMailboxId = (autoMoved, mailboxes) => {
|
|
|
74
75
|
return undefined;
|
|
75
76
|
if (isFilterMove(autoMoved))
|
|
76
77
|
return autoMoved.fromMailboxId;
|
|
77
|
-
if (autoMoved.fromPlacement ===
|
|
78
|
+
if (autoMoved.fromPlacement === FromPlacement.Inbox)
|
|
78
79
|
return mailboxes.inboxMailboxId;
|
|
79
|
-
if (autoMoved.fromPlacement ===
|
|
80
|
+
if (autoMoved.fromPlacement === FromPlacement.Junk)
|
|
80
81
|
return mailboxes.junkMailboxId;
|
|
81
82
|
return undefined;
|
|
82
83
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { RemitImapMailboxResponse } from "@remit/api-http-client/types.gen.ts";
|
|
2
2
|
export declare const folderFailure: (mailbox: Pick<RemitImapMailboxResponse, "syncStatus" | "syncFailureReason">) => string | undefined;
|
|
3
|
+
export declare const folderUnavailable: (mailbox: Pick<RemitImapMailboxResponse, "statusRefused">) => string | undefined;
|
|
@@ -6,3 +6,6 @@ export const folderFailure = (mailbox) => {
|
|
|
6
6
|
return "The last change to this folder failed.";
|
|
7
7
|
return `The mail server refused the last change: ${reason}`;
|
|
8
8
|
};
|
|
9
|
+
export const folderUnavailable = (mailbox) => mailbox.statusRefused
|
|
10
|
+
? "The mail server refuses to open this folder. Check its permissions on the server, or unsubscribe from it."
|
|
11
|
+
: undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ListPage<T> {
|
|
2
|
+
items: T[];
|
|
3
|
+
continuationToken?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Follow a list endpoint's `continuationToken` and yield each page's items,
|
|
7
|
+
* stopping at the last page, after `maxPages` when given, or once `signal`
|
|
8
|
+
* aborts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function listPages<T>(fetchPage: (continuationToken: string | undefined) => Promise<ListPage<T>>, { maxPages, signal, }?: {
|
|
11
|
+
maxPages?: number;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): AsyncGenerator<T[]>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Follow a list endpoint's `continuationToken` and yield each page's items,
|
|
3
|
+
* stopping at the last page, after `maxPages` when given, or once `signal`
|
|
4
|
+
* aborts.
|
|
5
|
+
*/
|
|
6
|
+
export async function* listPages(fetchPage, { maxPages = Number.POSITIVE_INFINITY, signal, } = {}) {
|
|
7
|
+
let continuationToken;
|
|
8
|
+
for (let page = 0; page < maxPages; page += 1) {
|
|
9
|
+
if (signal?.aborted)
|
|
10
|
+
return;
|
|
11
|
+
const data = await fetchPage(continuationToken);
|
|
12
|
+
yield data.items;
|
|
13
|
+
if (!data.continuationToken)
|
|
14
|
+
return;
|
|
15
|
+
continuationToken = data.continuationToken;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -9,9 +9,8 @@ export declare const Route: import("@tanstack/router-core").Route<import("@tanst
|
|
|
9
9
|
}>>;
|
|
10
10
|
}, z.core.$strip>, import("@tanstack/router-core").ResolveParams<"/senders">, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, import("@tanstack/router-core").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
|
|
11
11
|
type SenderGroup = (typeof SENDER_GROUPS)[number];
|
|
12
|
-
type SearchGroup = Exclude<SenderGroup, "vip">;
|
|
13
12
|
export declare function SearchGroupPane({ group, query, onCount, }: {
|
|
14
|
-
group:
|
|
13
|
+
group: SenderGroup;
|
|
15
14
|
query: string;
|
|
16
15
|
onCount?: (matched: number, total: number | null) => void;
|
|
17
16
|
}): import("react").JSX.Element;
|
|
@@ -3,12 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Senders & Rules — 2-pane page: rule groups left, dense filterable
|
|
4
4
|
* sender table right. Built to scale to hundreds of flagged senders.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* flagged senders via GET /addresses/search; results are filtered client-side
|
|
10
|
-
* on the flag, because the search takes no flag filter (spam spec gap 1).
|
|
11
|
-
* The real flagged-address query endpoint is tracked as a backend issue.
|
|
6
|
+
* VIP, Blocked and Never in Spam list their whole group from
|
|
7
|
+
* GET /addresses/search with the `flag` filter. Muted has no server-side
|
|
8
|
+
* filter, so its senders are found by searching and filtered on the flag here.
|
|
12
9
|
*/
|
|
13
10
|
import { addressDetailOperationsUpdateAddressMutation, addressOperationsSearchAddressesOptions, meOperationsListVipSuggestionsOptions, meOperationsListVipSuggestionsQueryKey, } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
14
11
|
import { Button, ErrorState, Input, Kbd, SenderFlagRow, SenderGroupSwitch, SettingsShell, } from "@remit/ui";
|
|
@@ -36,7 +33,9 @@ const groupLabels = {
|
|
|
36
33
|
blocked: "Blocked (reported)",
|
|
37
34
|
neverSpam: "Never in Spam",
|
|
38
35
|
};
|
|
36
|
+
const FLAGGED_GROUP_LIMIT = 500;
|
|
39
37
|
const groupNouns = {
|
|
38
|
+
vip: "VIP",
|
|
40
39
|
muted: "muted",
|
|
41
40
|
blocked: "blocked",
|
|
42
41
|
neverSpam: "never-in-spam",
|
|
@@ -45,7 +44,7 @@ const flagOf = (address, group) => address.flags?.[group];
|
|
|
45
44
|
/* ------------------------------------------------------------------ */
|
|
46
45
|
/* VIP group: served from suggestions endpoint */
|
|
47
46
|
/* ------------------------------------------------------------------ */
|
|
48
|
-
function VipGroupPane({ query
|
|
47
|
+
function VipGroupPane({ query }) {
|
|
49
48
|
const { data, isPending, isError, error } = useQuery(meOperationsListVipSuggestionsOptions());
|
|
50
49
|
const queryClient = useQueryClient();
|
|
51
50
|
const addMutation = useMutation({
|
|
@@ -54,6 +53,9 @@ function VipGroupPane({ query, onCount, }) {
|
|
|
54
53
|
queryClient.invalidateQueries({
|
|
55
54
|
queryKey: meOperationsListVipSuggestionsQueryKey(),
|
|
56
55
|
});
|
|
56
|
+
queryClient.invalidateQueries({
|
|
57
|
+
queryKey: [{ _id: "addressOperationsSearchAddresses" }],
|
|
58
|
+
});
|
|
57
59
|
},
|
|
58
60
|
});
|
|
59
61
|
const suggestions = data?.suggestions ?? [];
|
|
@@ -62,9 +64,6 @@ function VipGroupPane({ query, onCount, }) {
|
|
|
62
64
|
? suggestions.filter((s) => (s.displayName ?? "").toLowerCase().includes(q) ||
|
|
63
65
|
s.normalizedEmail.toLowerCase().includes(q))
|
|
64
66
|
: suggestions;
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
onCount?.(filtered.length, suggestions.length);
|
|
67
|
-
}, [onCount, filtered.length, suggestions.length]);
|
|
68
67
|
if (isPending) {
|
|
69
68
|
return (_jsx("div", { className: "px-row-inset py-3 text-sm text-fg-subtle animate-pulse", children: "Loading VIP suggestions\u2026" }));
|
|
70
69
|
}
|
|
@@ -93,15 +92,20 @@ function VipGroupPane({ query, onCount, }) {
|
|
|
93
92
|
}, children: "Add VIP" }) }, s.addressId)))] }));
|
|
94
93
|
}
|
|
95
94
|
/* ------------------------------------------------------------------ */
|
|
96
|
-
/*
|
|
95
|
+
/* Flag groups: listed through the address search */
|
|
97
96
|
/* ------------------------------------------------------------------ */
|
|
98
97
|
export function SearchGroupPane({ group, query, onCount, }) {
|
|
99
98
|
const debouncedQ = useDebouncedValue(query.trim(), 300);
|
|
100
99
|
const queryClient = useQueryClient();
|
|
101
100
|
const [retryId, setRetryId] = useState(null);
|
|
102
|
-
const
|
|
101
|
+
const trustFlag = group === "muted" ? undefined : group;
|
|
102
|
+
const enabled = trustFlag !== undefined || debouncedQ.length >= 2;
|
|
103
103
|
const searchOptions = addressOperationsSearchAddressesOptions({
|
|
104
|
-
query: {
|
|
104
|
+
query: {
|
|
105
|
+
q: debouncedQ,
|
|
106
|
+
limit: trustFlag ? FLAGGED_GROUP_LIMIT : 50,
|
|
107
|
+
flag: trustFlag,
|
|
108
|
+
},
|
|
105
109
|
});
|
|
106
110
|
const { data, isPending, isError, error } = useQuery({
|
|
107
111
|
...searchOptions,
|
|
@@ -113,15 +117,14 @@ export function SearchGroupPane({ group, query, onCount, }) {
|
|
|
113
117
|
queryClient.invalidateQueries({ queryKey: searchOptions.queryKey });
|
|
114
118
|
},
|
|
115
119
|
});
|
|
116
|
-
const items =
|
|
120
|
+
const items = trustFlag
|
|
121
|
+
? (data?.items ?? [])
|
|
122
|
+
: (data?.items ?? []).filter((a) => flagOf(a, group)?.value ?? false);
|
|
117
123
|
useEffect(() => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
onCount?.(enabled ? items.length : 0, null);
|
|
121
|
-
}, [onCount, enabled, items.length]);
|
|
124
|
+
onCount?.(enabled ? items.length : 0, trustFlag ? items.length : null);
|
|
125
|
+
}, [onCount, enabled, items.length, trustFlag]);
|
|
122
126
|
if (!enabled) {
|
|
123
|
-
|
|
124
|
-
return (_jsxs("div", { className: "px-row-inset py-5 text-sm text-fg-subtle space-y-2", children: [_jsxs("p", { children: ["Type 2+ characters to search ", groupNouns[group], " senders by name or address."] }), _jsxs("p", { className: "text-2xs text-fg-subtle", children: ["Note: a dedicated flagged-address list endpoint is in the backlog. Press ", _jsx(Kbd, { children: "m" }), " on any message to mute its sender; ", _jsx(Kbd, { children: "b" }), " to block."] })] }));
|
|
127
|
+
return (_jsxs("div", { className: "px-row-inset py-5 text-sm text-fg-subtle space-y-2", children: [_jsxs("p", { children: ["Type 2+ characters to search ", groupNouns[group], " senders by name or address."] }), _jsxs("p", { className: "text-2xs text-fg-subtle", children: ["Press ", _jsx(Kbd, { children: "m" }), " on any message to mute its sender; ", _jsx(Kbd, { children: "b" }), " to block."] })] }));
|
|
125
128
|
}
|
|
126
129
|
if (isPending) {
|
|
127
130
|
return (_jsx("div", { className: "px-row-inset py-3 text-sm text-fg-subtle animate-pulse", children: "Searching\u2026" }));
|
|
@@ -130,7 +133,9 @@ export function SearchGroupPane({ group, query, onCount, }) {
|
|
|
130
133
|
return (_jsx("div", { className: "px-row-inset py-3", children: _jsx(ErrorState, { variant: "inline", title: "Search failed", error: error }) }));
|
|
131
134
|
}
|
|
132
135
|
if (items.length === 0) {
|
|
133
|
-
return (
|
|
136
|
+
return (_jsx("p", { className: "px-row-inset py-5 text-sm text-fg-subtle", children: debouncedQ
|
|
137
|
+
? `No ${groupNouns[group]} senders matching \u201c${debouncedQ}\u201d.`
|
|
138
|
+
: `No ${groupNouns[group]} senders yet.` }));
|
|
134
139
|
}
|
|
135
140
|
return (_jsx(_Fragment, { children: items.map((a) => {
|
|
136
141
|
const flag = flagOf(a, group);
|
|
@@ -190,15 +195,8 @@ function SendersSettings() {
|
|
|
190
195
|
});
|
|
191
196
|
const [query, setQuery] = useState("");
|
|
192
197
|
const [helpOpen, setHelpOpen] = useState(true);
|
|
193
|
-
// Per-group counts for the rail + footer. VIP total is the suggestions
|
|
194
|
-
// list size; muted/blocked have no list endpoint, so their total is null
|
|
195
|
-
// (the rail shows the live matched-row count instead of a stale total).
|
|
196
198
|
const [matched, setMatched] = useState(0);
|
|
197
|
-
const [groupCounts, setGroupCounts] = useState({ vip:
|
|
198
|
-
const handleVipCount = useCallback((m, total) => {
|
|
199
|
-
setMatched(m);
|
|
200
|
-
setGroupCounts((prev) => ({ ...prev, vip: total }));
|
|
201
|
-
}, []);
|
|
199
|
+
const [groupCounts, setGroupCounts] = useState({ vip: null, muted: null, blocked: null, neverSpam: null });
|
|
202
200
|
const handleSearchCount = useCallback((m, _total) => {
|
|
203
201
|
setMatched(m);
|
|
204
202
|
setGroupCounts((prev) => ({ ...prev, [group]: m }));
|
|
@@ -211,7 +209,7 @@ function SendersSettings() {
|
|
|
211
209
|
id: g,
|
|
212
210
|
label: groupLabels[g],
|
|
213
211
|
count: groupCounts[g],
|
|
214
|
-
})) }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("div", { className: "border-b border-line px-row-inset py-2", children: _jsx(Input, { icon: _jsx(Search, { className: "size-4" }), placeholder: `Filter ${groupLabels[group].toLowerCase()} by name or address`, className: "h-8 max-w-sm", value: query, onChange: (e) => setQuery(e.target.value) }) }),
|
|
212
|
+
})) }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("div", { className: "border-b border-line px-row-inset py-2", children: _jsx(Input, { icon: _jsx(Search, { className: "size-4" }), placeholder: `Filter ${groupLabels[group].toLowerCase()} by name or address`, className: "h-8 max-w-sm", value: query, onChange: (e) => setQuery(e.target.value) }) }), _jsxs("div", { className: "min-h-0 flex-1 divide-y divide-line overflow-y-auto", children: [_jsx(SearchGroupPane, { group: group, query: query, onCount: handleSearchCount }), group === "vip" && _jsx(VipGroupPane, { query: query })] }), _jsxs("footer", { className: "flex items-center justify-between border-t border-line px-row-inset py-1 text-2xs text-fg-subtle", children: [_jsx("span", { children: total != null
|
|
215
213
|
? `${matched} of ${total} flagged senders`
|
|
216
214
|
: `${matched} flagged senders` }), _jsxs("span", { children: [_jsx(Kbd, { children: "j" }), " ", _jsx(Kbd, { children: "k" }), " navigate \u00B7 ", _jsx(Kbd, { children: "\u232B" }), " remove flag"] })] })] })] }) }));
|
|
217
215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.352",
|
|
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.243",
|
|
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",
|