@remit/web-client 0.0.350 → 0.0.351
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.
|
@@ -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.351",
|
|
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.242",
|
|
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",
|