@remit/web-client 0.0.348 → 0.0.350
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/CheckAgainProvider.js +6 -0
- package/dist/src/components/mail/DailyBrief.js +5 -2
- package/dist/src/components/mail/MailSidebarAdapter.js +18 -6
- package/dist/src/components/ui/error-banners.d.ts +1 -0
- package/dist/src/components/ui/error-banners.js +1 -0
- package/dist/src/hooks/useCollectionThreads.d.ts +5 -0
- package/dist/src/hooks/useCollectionThreads.js +22 -4
- package/dist/src/lib/result-folder.js +7 -0
- package/package.json +2 -2
|
@@ -45,6 +45,7 @@ export function CheckAgainProvider({ children }) {
|
|
|
45
45
|
const [failures, setFailures] = useState(new Map());
|
|
46
46
|
const runningRef = useRef(false);
|
|
47
47
|
const stopRef = useRef(false);
|
|
48
|
+
const startRef = useRef(undefined);
|
|
48
49
|
const settle = useCallback((targets) => {
|
|
49
50
|
invalidateThreadListQueries(queryClient, threadListCacheKeys(targets.map((target) => target.mailboxId)));
|
|
50
51
|
for (const threadId of new Set(targets.map((t) => t.threadId))) {
|
|
@@ -99,9 +100,13 @@ export function CheckAgainProvider({ children }) {
|
|
|
99
100
|
}
|
|
100
101
|
if (!showPanel) {
|
|
101
102
|
for (const failure of outcome.failures) {
|
|
103
|
+
const retryTarget = failure.retryable
|
|
104
|
+
? targets.find((target) => target.messageId === failure.messageId)
|
|
105
|
+
: undefined;
|
|
102
106
|
pushError({
|
|
103
107
|
title: "Couldn't check this message again",
|
|
104
108
|
detail: `${failure.subject}: ${CHECK_AGAIN_FAILURE_SENTENCES[failure.code]}`,
|
|
109
|
+
onRetry: retryTarget && (() => startRef.current?.([retryTarget], false)),
|
|
105
110
|
});
|
|
106
111
|
}
|
|
107
112
|
return;
|
|
@@ -142,6 +147,7 @@ export function CheckAgainProvider({ children }) {
|
|
|
142
147
|
runningRef.current = false;
|
|
143
148
|
});
|
|
144
149
|
}, [run, pushError]);
|
|
150
|
+
startRef.current = start;
|
|
145
151
|
const checkAgain = useCallback((requests, options) => {
|
|
146
152
|
start([...requests], options.panel);
|
|
147
153
|
}, [start]);
|
|
@@ -79,7 +79,7 @@ import { junkDestination } from "../../lib/junk-destination";
|
|
|
79
79
|
import { useMailContext } from "../../lib/mail-context";
|
|
80
80
|
import { useMailFreshness } from "../../lib/mail-freshness";
|
|
81
81
|
import { shouldRequestResultCount } from "../../lib/result-count";
|
|
82
|
-
import { junkMailboxIds } from "../../lib/result-folder";
|
|
82
|
+
import { junkMailboxIds, resolveResultFolder } from "../../lib/result-folder";
|
|
83
83
|
import { rowToSearchResult } from "../../lib/search-result";
|
|
84
84
|
import { showInlineSearchResults } from "../../lib/search-surface";
|
|
85
85
|
import { parseSearchTokens } from "../../lib/search-tokens";
|
|
@@ -377,7 +377,10 @@ export function DailyBrief({ accounts, selectedMessageId, onOpenThread, commands
|
|
|
377
377
|
failed: section.failed,
|
|
378
378
|
rows: narrowRows(section.rows),
|
|
379
379
|
})), [sectionRows, narrowRows]);
|
|
380
|
-
const matchRows = useMemo(() => narrowRows(searchRows)
|
|
380
|
+
const matchRows = useMemo(() => narrowRows(searchRows).map((row) => {
|
|
381
|
+
const { folder } = resolveResultFolder(resultFolderIndex, row.mailboxId ? [row.mailboxId] : []);
|
|
382
|
+
return folder ? { ...row, folder } : row;
|
|
383
|
+
}), [searchRows, narrowRows, resultFolderIndex]);
|
|
381
384
|
// Each section answers for itself, so a retry is that section's own request.
|
|
382
385
|
const retrySection = useCallback((sectionId) => {
|
|
383
386
|
sectionRows.find((section) => section.category === sectionId)?.retry();
|
|
@@ -4,6 +4,7 @@ import { NavSidebar } from "@remit/ui";
|
|
|
4
4
|
import { useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { useCallback, useMemo } from "react";
|
|
6
6
|
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { useLabelUnreadCounts } from "../../hooks/useCollectionThreads";
|
|
7
8
|
import { useLabelList } from "../../hooks/useLabels";
|
|
8
9
|
import { folderFailure } from "../../lib/folder-failure";
|
|
9
10
|
import { buildMailboxRoleMap, labelForMailbox, shouldShowUnreadBadgeForRole, } from "../../lib/folder-roles";
|
|
@@ -60,6 +61,17 @@ function toNavMailbox(mb, role, t) {
|
|
|
60
61
|
failure: folderFailure(mb),
|
|
61
62
|
};
|
|
62
63
|
}
|
|
64
|
+
function toNavLabels(labels, unreadByLabel) {
|
|
65
|
+
return labels.map((label) => {
|
|
66
|
+
const unseen = unreadByLabel.get(label.labelId) ?? 0;
|
|
67
|
+
return {
|
|
68
|
+
id: labelNavId(label.labelId),
|
|
69
|
+
name: label.name,
|
|
70
|
+
color: label.color,
|
|
71
|
+
unseen: unseen > 0 ? unseen : undefined,
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
63
75
|
/**
|
|
64
76
|
* Pane 1 of the 4-pane shell. Data bridge that fetches mailboxes per account,
|
|
65
77
|
* maps them onto the kit's NavAccount shape, and renders each entry as a real
|
|
@@ -85,17 +97,16 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
|
|
|
85
97
|
// before its label is known. A failed label list leaves the tree whole.
|
|
86
98
|
const { labels, isPending: labelsPending, isError: labelsFailed, } = useLabelList(accounts[0]?.accountId);
|
|
87
99
|
const labelsSettled = !labelsPending || labelsFailed;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
color: label.color,
|
|
92
|
-
})), [labels]);
|
|
100
|
+
const labelIds = useMemo(() => labels.map((label) => label.labelId), [labels]);
|
|
101
|
+
const unreadByLabel = useLabelUnreadCounts(labelIds);
|
|
102
|
+
const navLabels = useMemo(() => toNavLabels(labels, unreadByLabel), [labels, unreadByLabel]);
|
|
93
103
|
const { data: outboxResponse } = useQuery(outboxOperationsListOutboxMessagesOptions());
|
|
94
104
|
const outboxPendingCount = useMemo(() => (outboxResponse?.items ?? []).filter((item) => isOutboxListRow(item.status)).length, [outboxResponse?.items]);
|
|
95
105
|
const navAccounts = useMemo(() => {
|
|
96
106
|
return accounts.map((account, i) => {
|
|
97
107
|
const query = mailboxQueries[i];
|
|
98
|
-
const
|
|
108
|
+
const allMailboxes = query?.data?.items ?? [];
|
|
109
|
+
const mailboxes = withoutLabelFolders(allMailboxes, labels);
|
|
99
110
|
const roleMap = buildMailboxRoleMap(account.folderAppointments);
|
|
100
111
|
const { system, labels: folders } = sortMailboxes(mailboxes, roleMap, translator);
|
|
101
112
|
const status = query?.isError
|
|
@@ -107,6 +118,7 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
|
|
|
107
118
|
id: account.accountId,
|
|
108
119
|
label: account.email,
|
|
109
120
|
email: account.email,
|
|
121
|
+
hierarchyDelimiter: allMailboxes[0]?.hierarchyDelimiter ?? "",
|
|
110
122
|
muted: Boolean(account.muted),
|
|
111
123
|
// Outbox is a shared singleton shown inside each account's section,
|
|
112
124
|
// matching existing sidebar behaviour.
|
|
@@ -4,6 +4,7 @@ export interface PushErrorInput {
|
|
|
4
4
|
title: string;
|
|
5
5
|
detail?: string;
|
|
6
6
|
action?: ErrorBannerAction;
|
|
7
|
+
onRetry?: () => void;
|
|
7
8
|
/**
|
|
8
9
|
* The error being reported, when there is one. Pass it: a banner is a soft
|
|
9
10
|
* surface, and `pushError` uses this to refuse errors that are not soft —
|
|
@@ -41,4 +41,9 @@ export declare function useCollectionThreads(collection: ThreadCollection, crite
|
|
|
41
41
|
* shows no number rather than a made-up one.
|
|
42
42
|
*/
|
|
43
43
|
export declare function useCollectionUnreadCount(collection: ThreadCollection, criteria?: CollectionCriteria): number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Each label's unread count, from the request the label list's header makes,
|
|
46
|
+
* so a sidebar badge and the list it opens count the same conversations.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useLabelUnreadCounts(labelIds: readonly string[]): ReadonlyMap<string, number>;
|
|
44
49
|
export {};
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { unifiedThreadOperationsListAllThreadsQueryKey } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
27
27
|
import { unifiedThreadOperationsListAllThreads } from "@remit/api-http-client/sdk.gen.ts";
|
|
28
|
-
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
|
|
28
|
+
import { useInfiniteQuery, useQueries, useQuery } from "@tanstack/react-query";
|
|
29
29
|
import { useMemo } from "react";
|
|
30
30
|
// The collection and `order` are the view itself, not a criterion, so they are
|
|
31
31
|
// set last: no chip can widen the listing past the collection or reorder it.
|
|
@@ -81,13 +81,32 @@ export function useCollectionThreads(collection, criteria = {}) {
|
|
|
81
81
|
* shows no number rather than a made-up one.
|
|
82
82
|
*/
|
|
83
83
|
export function useCollectionUnreadCount(collection, criteria = {}) {
|
|
84
|
+
const { data } = useQuery(unreadCountOptions(collection, criteria));
|
|
85
|
+
return data?.count;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Each label's unread count, from the request the label list's header makes,
|
|
89
|
+
* so a sidebar badge and the list it opens count the same conversations.
|
|
90
|
+
*/
|
|
91
|
+
export function useLabelUnreadCounts(labelIds) {
|
|
92
|
+
const counts = useQueries({
|
|
93
|
+
queries: labelIds.map((labelId) => unreadCountOptions({ labelId })),
|
|
94
|
+
combine: countsOf,
|
|
95
|
+
});
|
|
96
|
+
return useMemo(() => new Map(labelIds.flatMap((labelId, index) => {
|
|
97
|
+
const count = counts[index];
|
|
98
|
+
return count === undefined ? [] : [[labelId, count]];
|
|
99
|
+
})), [labelIds, counts]);
|
|
100
|
+
}
|
|
101
|
+
const countsOf = (results) => results.map((result) => result.data?.count);
|
|
102
|
+
function unreadCountOptions(collection, criteria = {}) {
|
|
84
103
|
const query = {
|
|
85
104
|
...collectionQuery(collection, criteria),
|
|
86
105
|
unread: true,
|
|
87
106
|
count: true,
|
|
88
107
|
results: false,
|
|
89
108
|
};
|
|
90
|
-
|
|
109
|
+
return {
|
|
91
110
|
queryKey: unifiedThreadOperationsListAllThreadsQueryKey({ query }),
|
|
92
111
|
queryFn: async () => {
|
|
93
112
|
const { data: page } = await unifiedThreadOperationsListAllThreads({
|
|
@@ -97,6 +116,5 @@ export function useCollectionUnreadCount(collection, criteria = {}) {
|
|
|
97
116
|
return page;
|
|
98
117
|
},
|
|
99
118
|
staleTime: 60_000,
|
|
100
|
-
}
|
|
101
|
-
return data?.count;
|
|
119
|
+
};
|
|
102
120
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { provenanceFolderLabel } from "@remit/ui";
|
|
2
2
|
import { buildMailboxRoleMap } from "./folder-roles.js";
|
|
3
3
|
export const EMPTY_RESULT_FOLDER_INDEX = new Map();
|
|
4
|
+
function isLabelFolderPath({ fullPath, hierarchyDelimiter, }) {
|
|
5
|
+
return fullPath
|
|
6
|
+
.split(hierarchyDelimiter)
|
|
7
|
+
.some((segment) => segment.endsWith("_remit"));
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* The appointments and the mailbox list arrive from two different queries, so
|
|
6
11
|
* the roles are seeded first and the provider paths laid over them. A role on
|
|
@@ -14,6 +19,8 @@ export function buildResultFolderIndex(accounts) {
|
|
|
14
19
|
for (const [mailboxId, role] of roles)
|
|
15
20
|
index.set(mailboxId, { role });
|
|
16
21
|
for (const mailbox of account.mailboxes) {
|
|
22
|
+
if (isLabelFolderPath(mailbox))
|
|
23
|
+
continue;
|
|
17
24
|
const role = roles.get(mailbox.mailboxId);
|
|
18
25
|
const path = {
|
|
19
26
|
providerPath: mailbox.fullPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.350",
|
|
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.241",
|
|
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",
|