@remit/web-client 0.0.345 → 0.0.347

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.
Files changed (58) hide show
  1. package/dist/src/components/mail/{FlaggedList.d.ts → CollectionList.d.ts} +7 -3
  2. package/dist/src/components/mail/{FlaggedList.js → CollectionList.js} +25 -22
  3. package/dist/src/components/mail/CollectionPane.d.ts +32 -0
  4. package/dist/src/components/mail/{FlaggedPane.js → CollectionPane.js} +32 -30
  5. package/dist/src/components/mail/MailSidebarAdapter.js +29 -7
  6. package/dist/src/hooks/{useStarredThreads.d.ts → useCollectionThreads.d.ts} +10 -8
  7. package/dist/src/hooks/{useStarredThreads.js → useCollectionThreads.js} +16 -14
  8. package/dist/src/hooks/useCurrentMailboxName.d.ts +1 -0
  9. package/dist/src/hooks/useCurrentMailboxName.js +6 -1
  10. package/dist/src/hooks/useLabels.d.ts +10 -9
  11. package/dist/src/hooks/useLabels.js +25 -6
  12. package/dist/src/lib/{flagged-criteria.d.ts → collection-criteria.d.ts} +18 -6
  13. package/dist/src/lib/{flagged-criteria.js → collection-criteria.js} +4 -3
  14. package/dist/src/lib/label-folders.d.ts +6 -0
  15. package/dist/src/lib/label-folders.js +10 -0
  16. package/dist/src/lib/mail-route.d.ts +10 -5
  17. package/dist/src/lib/mail-route.js +9 -1
  18. package/dist/src/lib/mail-search.d.ts +11 -0
  19. package/dist/src/lib/mail-search.js +4 -0
  20. package/dist/src/lib/search-scope.d.ts +2 -2
  21. package/dist/src/lib/search-scope.js +4 -4
  22. package/dist/src/lib/search-tokens.d.ts +1 -1
  23. package/dist/src/lib/search-tokens.js +2 -2
  24. package/dist/src/routeTree.gen.d.ts +288 -3
  25. package/dist/src/routeTree.gen.js +65 -0
  26. package/dist/src/routes/mail/flagged/$threadId/$messageId.js +2 -2
  27. package/dist/src/routes/mail/flagged/$threadId/index.js +2 -2
  28. package/dist/src/routes/mail/flagged/index.js +2 -2
  29. package/dist/src/routes/mail/flagged.js +3 -2
  30. package/dist/src/routes/mail/label/$labelId/$threadId/$messageId/$mode.{-$outboxMessageId}.d.ts +18 -0
  31. package/dist/src/routes/mail/label/$labelId/$threadId/$messageId/$mode.{-$outboxMessageId}.js +8 -0
  32. package/dist/src/routes/mail/label/$labelId/$threadId/$messageId.d.ts +15 -0
  33. package/dist/src/routes/mail/label/$labelId/$threadId/$messageId.js +14 -0
  34. package/dist/src/routes/mail/label/$labelId/$threadId/index.d.ts +15 -0
  35. package/dist/src/routes/mail/label/$labelId/$threadId/index.js +9 -0
  36. package/dist/src/routes/mail/label/$labelId/$threadId.d.ts +15 -0
  37. package/dist/src/routes/mail/label/$labelId/$threadId.js +8 -0
  38. package/dist/src/routes/mail/label/$labelId/compose.{-$outboxMessageId}.d.ts +15 -0
  39. package/dist/src/routes/mail/label/$labelId/compose.{-$outboxMessageId}.js +10 -0
  40. package/dist/src/routes/mail/label/$labelId/index.d.ts +15 -0
  41. package/dist/src/routes/mail/label/$labelId/index.js +9 -0
  42. package/dist/src/routes/mail/label/$labelId.d.ts +15 -0
  43. package/dist/src/routes/mail/label/$labelId.js +30 -0
  44. package/dist/src/routes/mail/label/index.d.ts +29 -0
  45. package/dist/src/routes/mail/label/index.js +18 -0
  46. package/dist/src/routing/browsed-list.d.ts +1 -1
  47. package/dist/src/routing/browsed-list.js +15 -4
  48. package/dist/src/routing/compose.js +10 -6
  49. package/dist/src/routing/index.d.ts +1 -1
  50. package/dist/src/routing/index.js +1 -1
  51. package/dist/src/routing/nav-selection.d.ts +5 -0
  52. package/dist/src/routing/nav-selection.js +15 -0
  53. package/dist/src/routing/open-thread.js +23 -3
  54. package/dist/src/routing/reply.js +28 -11
  55. package/dist/src/routing/search-mirror.d.ts +5 -0
  56. package/dist/src/routing/search-mirror.js +20 -2
  57. package/package.json +2 -2
  58. package/dist/src/components/mail/FlaggedPane.d.ts +0 -29
@@ -1,12 +1,16 @@
1
1
  import { type RefObject } from "react";
2
2
  import type { TriageContextUpdate } from "../../hooks/useTriageLayer";
3
+ import { type ThreadCollection } from "../../lib/collection-criteria";
3
4
  import type { OpenThreadTarget } from "../../routing";
4
5
  import type { MessageListCommands } from "./MessageList";
5
6
  import { type OpenMessageOptions } from "./ThreadListInteraction";
6
- interface FlaggedListProps {
7
+ interface CollectionListProps {
8
+ collection: ThreadCollection;
9
+ /** What the list header and the empty state call the collection. */
10
+ title: string;
7
11
  selectedMessageId?: string;
8
12
  /**
9
- * Opens a row. Every starred row names its thread, so a message filed outside
13
+ * Opens a row. Every row names its thread, so a message filed outside
10
14
  * the inbox opens by exactly the same route as one inside it.
11
15
  */
12
16
  onOpenThread?: (target: OpenThreadTarget, options?: OpenMessageOptions) => void;
@@ -16,5 +20,5 @@ interface FlaggedListProps {
16
20
  onTriageContextChange?: (context: TriageContextUpdate) => void;
17
21
  onDeleteMessages: (messageIds: string[]) => void;
18
22
  }
19
- export declare function FlaggedList({ selectedMessageId, onOpenThread, commandsRef, onTriageContextChange, onDeleteMessages, }: FlaggedListProps): import("react").JSX.Element;
23
+ export declare function CollectionList({ collection, title, selectedMessageId, onOpenThread, commandsRef, onTriageContextChange, onDeleteMessages, }: CollectionListProps): import("react").JSX.Element;
20
24
  export {};
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * FlaggedList — a FLAT, cross-account inbox of starred mail.
3
+ * CollectionList — a FLAT, cross-account inbox of starred mail, or of one
4
+ * label's mail.
4
5
  *
5
- * Reads the starred listing through `useStarredThreads` — GET /threads with
6
- * `starred=true`, served by the `byStarred` index — which returns every starred
7
- * thread in the config across all non-muted mailboxes, paged. Every row names
6
+ * Reads the collection listing through `useCollectionThreads` — GET /threads
7
+ * with `starred=true`, served by the `byStarred` index, or with `labelId`,
8
+ * which reads the label's folder in every non-muted account — paged. Every row names
8
9
  * its thread, which is the whole address a conversation opens by, so a starred
9
10
  * message filed outside the inbox opens like any other. Starredness is decided
10
11
  * server-side from `hasStars`; the client neither re-filters nor caps the set,
@@ -29,12 +30,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
30
  */
30
31
  import { flaggedFilterConfig, formatErrorMessage, MessageListPane, } from "@remit/ui";
31
32
  import { useCallback, useMemo, useState } from "react";
33
+ import { useCollectionThreads, useCollectionUnreadCount, } from "../../hooks/useCollectionThreads";
32
34
  import { useIsDesktop } from "../../hooks/useMediaQuery";
33
35
  import { useSearchTokenContext } from "../../hooks/useSearchTokenContext";
34
- import { useStarredThreads, useStarredUnreadCount, } from "../../hooks/useStarredThreads";
35
36
  import { matchesSearchTokens, toThreadRowData } from "../../lib/brief";
36
37
  import { buildBugReportContext, buildGitHubIssueUrl, } from "../../lib/bug-report";
37
- import { flaggedCriteria } from "../../lib/flagged-criteria";
38
+ import { collectionCriteria, } from "../../lib/collection-criteria";
38
39
  import { useListHeaderChrome } from "../../lib/list-header-chrome";
39
40
  import { listNarrowing } from "../../lib/list-narrowing";
40
41
  import { useMailContext } from "../../lib/mail-context";
@@ -55,16 +56,16 @@ import { ThreadListInteraction, ThreadListSelectionBar, useThreadListSelection,
55
56
  * offers "make this a filter" wherever a search is active, and the step that
56
57
  * affordance pushes has to be answered on the view that offered it — an
57
58
  * affordance whose press lands on nothing is the dead button clause 1.7 exists
58
- * to prevent. Starred spans accounts and mailboxes, so a rule made from the
59
+ * to prevent. A collection spans accounts and mailboxes, so a rule made from the
59
60
  * ticked rows has no single account to belong to; a rule made from the query
60
61
  * belongs to the account the query names, which the host reads for itself.
61
62
  */
62
- function StarredWizardHost({ rows, verb, }) {
63
+ function CollectionWizardHost({ rows, verb, }) {
63
64
  const { selectedIds, exitSelection } = useThreadListSelection();
64
65
  const selection = useMemo(() => wizardSelectionFrom(rows, selectedIds), [rows, selectedIds]);
65
66
  return (_jsx(SelectionWizardHost, { verb: verb, selection: selection, selectionRestriction: "spansAccounts", onFinished: exitSelection }));
66
67
  }
67
- export function FlaggedList({ selectedMessageId, onOpenThread, commandsRef, onTriageContextChange, onDeleteMessages, }) {
68
+ export function CollectionList({ collection, title, selectedMessageId, onOpenThread, commandsRef, onTriageContextChange, onDeleteMessages, }) {
68
69
  const { searchQuery, resultFolderIndex, onSearchClearQuery } = useMailContext();
69
70
  const tokenContext = useSearchTokenContext();
70
71
  const isDesktop = useIsDesktop();
@@ -98,13 +99,13 @@ export function FlaggedList({ selectedMessageId, onOpenThread, commandsRef, onTr
98
99
  const typedFreeText = parseSearchTokens(searchQuery.trim(), tokenContext).freeText;
99
100
  // The chips and the tokens together, as query parameters: a category typed as
100
101
  // `category:personal` narrows the request exactly as the chip does.
101
- const { criteria, residual: residualTokens } = useMemo(() => flaggedCriteria({ category: selectedCategory, attributes: activeFilters }, queryTokens), [selectedCategory, activeFilters, queryTokens]);
102
+ const { criteria, residual: residualTokens } = useMemo(() => collectionCriteria(collection, { category: selectedCategory, attributes: activeFilters }, queryTokens), [collection, selectedCategory, activeFilters, queryTokens]);
102
103
  const textCriteria = useMemo(() => (sq ? { ...criteria, query: sq } : criteria), [criteria, sq]);
103
104
  // One request, free text included. The text is a parameter like every other
104
105
  // criterion, so a search is this listing narrowed rather than a second query
105
106
  // beside it — which is what gives a search the same error state, the same
106
107
  // pagination and the same loading state as the unsearched list.
107
- const { threads, isLoading, isError, error, refetch, fetchNextPage, hasNextPage, isFetchingNextPage, } = useStarredThreads(textCriteria);
108
+ const { threads, isLoading, isError, error, refetch, fetchNextPage, hasNextPage, isFetchingNextPage, } = useCollectionThreads(collection, textCriteria);
108
109
  const rows = useMemo(() =>
109
110
  // What is left is what no parameter can carry: `before:`, `after:`,
110
111
  // `in:`, `account:`, and a token the chips overruled.
@@ -129,15 +130,17 @@ export function FlaggedList({ selectedMessageId, onOpenThread, commandsRef, onTr
129
130
  // The server's count over the whole collection under the active criteria.
130
131
  // `null` while it is in flight and `null` when it cannot be had, and the
131
132
  // header then shows no number — never a page length dressed as a total.
132
- const unreadCount = useStarredUnreadCount(textCriteria) ?? null;
133
+ const unreadCount = useCollectionUnreadCount(collection, textCriteria) ?? null;
133
134
  // An empty list has to say how much was looked at, and the answer comes off
134
135
  // the request. Every chip, the free text and every carried token is a field
135
136
  // on the row, so the server answered each over the whole collection; only a
136
137
  // residual token — a date, a mailbox, an account — saw the loaded pages.
137
138
  //
138
- // `is:starred` is dropped: this view is starred mail, so the token restates
139
- // the collection rather than narrowing it.
140
- const narrowingTokens = useMemo(() => queryTokens.filter((token) => token.type !== "isStarred"), [queryTokens]);
139
+ // On Starred, `is:starred` is dropped: the token restates the collection
140
+ // rather than narrowing it.
141
+ const narrowingTokens = useMemo(() => "starred" in collection
142
+ ? queryTokens.filter((token) => token.type !== "isStarred")
143
+ : queryTokens, [collection, queryTokens]);
141
144
  const listFilter = listNarrowing({
142
145
  chips: { category: selectedCategory, attributes: activeFilters },
143
146
  tokens: narrowingTokens,
@@ -157,17 +160,17 @@ export function FlaggedList({ selectedMessageId, onOpenThread, commandsRef, onTr
157
160
  }, []);
158
161
  const chrome = useListHeaderChrome();
159
162
  const listBody = (_jsx("div", { className: "flex h-full min-h-0 flex-col", children: _jsxs("div", { className: "flex-1 overflow-y-auto", children: [_jsx("div", { className: "divide-y divide-line", children: rows.map((thread) => (_jsx(MessageRow, { thread: thread, active: thread.id === selectedMessageId, onClick: () => openRow(thread.id) }, thread.id))) }), hasNextPage ? (_jsx("button", { type: "button", className: "w-full py-3 text-sm text-muted hover:text-fg disabled:opacity-50", onClick: () => fetchNextPage(), disabled: isFetchingNextPage, children: isFetchingNextPage ? "Loading…" : "Load more" })) : null] }) }));
160
- return (_jsx(MailViewChrome, { title: "Starred", unreadCount: unreadCount, preset: preset, selectedCategory: selectedCategory, activeFilters: activeFilters, onSelectCategory: setSelectedCategory, onToggleFilter: toggleFilter, onClearFilters: clearFilters, searchResults: searchResults, searchLoading: isLoading, onSelectSearchResult: openResult,
163
+ return (_jsx(MailViewChrome, { title: title, unreadCount: unreadCount, preset: preset, selectedCategory: selectedCategory, activeFilters: activeFilters, onSelectCategory: setSelectedCategory, onToggleFilter: toggleFilter, onClearFilters: clearFilters, searchResults: searchResults, searchLoading: isLoading, onSelectSearchResult: openResult,
161
164
  // A committed search renders in this view's own rows (`rows` already
162
165
  // narrows to the query above), so the multi-select toolbar stays
163
166
  // reachable exactly as it does on the mailbox route (#212). The
164
167
  // results panel stays for the typing/uncommitted state only.
165
- searchResultsInBody: true, children: _jsxs(ThreadListInteraction, { selectedMessageId: selectedMessageId, rows: rows, onOpen: openRow, onDeleteMessages: onDeleteMessages, onSelectionVerb: wizard.start, commandsRef: commandsRef, onTriageContextChange: onTriageContextChange, children: [_jsx(MessageListPane, { listTitle: "Starred", sections: [{ id: "flagged", threads: rows }], flatList: true, hideHeader: true, listState: chrome.searchResults ? "ready" : listState, listFilter: listFilter,
166
- // Flagged spans accounts and folders, so it is a collection and
167
- // never "this mailbox". It names itself.
168
- listScopeLabel: "Starred",
168
+ searchResultsInBody: true, children: _jsxs(ThreadListInteraction, { selectedMessageId: selectedMessageId, rows: rows, onOpen: openRow, onDeleteMessages: onDeleteMessages, onSelectionVerb: wizard.start, commandsRef: commandsRef, onTriageContextChange: onTriageContextChange, children: [_jsx(MessageListPane, { listTitle: title, sections: [{ id: "collection", threads: rows }], flatList: true, hideHeader: true, listState: chrome.searchResults ? "ready" : listState, listFilter: listFilter,
169
+ // A collection spans accounts and folders, so it is never "this
170
+ // mailbox". It names itself.
171
+ listScopeLabel: title,
169
172
  // The typed tokens narrow the list too, but `listFilter` already
170
173
  // names them, and a headline saying one narrowing twice reads as two.
171
- searchQuery: typedFreeText || undefined, errorMessage: isError ? formatErrorMessage(error) : undefined, onRetry: () => refetch(), onReportError: handleReportError, selectedThreadId: selectedMessageId, onSelectThread: openRow, isDesktop: isDesktop, selectionBar: _jsx(ThreadListSelectionBar, { title: "Starred" }), listBody: chrome.searchResults ??
172
- (listState === "ready" ? listBody : undefined) }), _jsx(StarredWizardHost, { rows: rows, verb: wizard.verb })] }) }));
174
+ searchQuery: typedFreeText || undefined, errorMessage: isError ? formatErrorMessage(error) : undefined, onRetry: () => refetch(), onReportError: handleReportError, selectedThreadId: selectedMessageId, onSelectThread: openRow, isDesktop: isDesktop, selectionBar: _jsx(ThreadListSelectionBar, { title: title }), listBody: chrome.searchResults ??
175
+ (listState === "ready" ? listBody : undefined) }), _jsx(CollectionWizardHost, { rows: rows, verb: wizard.verb })] }) }));
173
176
  }
@@ -0,0 +1,32 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ThreadCollection } from "../../lib/collection-criteria";
3
+ import { type OpenThreadPath } from "../../routing";
4
+ interface CollectionPaneProps {
5
+ collection: ThreadCollection;
6
+ title: string;
7
+ /** The open conversation, as the address states it. */
8
+ thread: OpenThreadPath | undefined;
9
+ children: ReactNode;
10
+ }
11
+ declare function CollectionPaneProvider({ collection, title, thread, children, }: CollectionPaneProps): import("react").JSX.Element;
12
+ /** Flat collection list. Mount in the `list` slot of `AppShellSlotted`. */
13
+ declare function CollectionListSlot(): import("react").JSX.Element;
14
+ /**
15
+ * Reading pane: toolbar + ConversationView.
16
+ * Mount in the `reading` slot of `AppShellSlotted`. Only rendered ≥ 1024px.
17
+ */
18
+ declare function CollectionReading(): import("react").JSX.Element;
19
+ /**
20
+ * Intelligence pane: IntelligencePane for the open thread.
21
+ * Mount in the `intelligence` slot of `AppShellSlotted`. Only rendered ≥ 1280px.
22
+ */
23
+ declare function CollectionIntelligence(): import("react").JSX.Element;
24
+ /** Phone view: ConversationView when a thread is open, else the flat list. */
25
+ declare function CollectionPhone(): import("react").JSX.Element;
26
+ declare const CollectionPane: typeof CollectionPaneProvider & {
27
+ List: typeof CollectionListSlot;
28
+ Reading: typeof CollectionReading;
29
+ Intelligence: typeof CollectionIntelligence;
30
+ Phone: typeof CollectionPhone;
31
+ };
32
+ export { CollectionPane };
@@ -1,41 +1,41 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { ReadingPaneEmpty } from "@remit/ui";
3
3
  import { createContext, useCallback, useContext, useMemo, } from "react";
4
+ import { useCollectionThreads } from "../../hooks/useCollectionThreads";
4
5
  import { useDeleteMessages } from "../../hooks/useDeleteMessages";
5
6
  import { useIntelligenceDrawer } from "../../hooks/useIntelligenceDrawer";
6
7
  import { useIntelligenceSurface } from "../../hooks/useIntelligenceSurface";
7
8
  import { useToggleReadFor } from "../../hooks/useMarkAsRead";
8
- import { useStarredThreads } from "../../hooks/useStarredThreads";
9
9
  import { useThreadActions, } from "../../hooks/useThreadActions";
10
10
  import { useThreadRow } from "../../hooks/useThreadRow";
11
11
  import { useTriageContext, useTriageLayer, } from "../../hooks/useTriageLayer";
12
12
  import { useMailContext } from "../../lib/mail-context";
13
13
  import { replyToThread, useCloseThread, useGoToSection, useIsComposing, useIsReplying, useOpenReply, useOpenThread, } from "../../routing";
14
14
  import { useReplyWithText } from "../compose/reply-with-times";
15
+ import { CollectionList } from "./CollectionList";
15
16
  import { ConversationView } from "./ConversationView";
16
- import { FlaggedList } from "./FlaggedList";
17
17
  import { IntelligenceDrawer } from "./IntelligenceDrawer";
18
18
  import { IntelligencePane } from "./IntelligencePane";
19
19
  import { MessageToolbar } from "./MessageToolbar";
20
- const FlaggedPaneCtx = createContext(null);
21
- function useFlaggedPane() {
22
- const ctx = useContext(FlaggedPaneCtx);
20
+ const CollectionPaneCtx = createContext(null);
21
+ function useCollectionPane() {
22
+ const ctx = useContext(CollectionPaneCtx);
23
23
  if (!ctx)
24
- throw new Error("FlaggedPane.* must be used inside <FlaggedPane>");
24
+ throw new Error("CollectionPane.* must be used inside <CollectionPane>");
25
25
  return ctx;
26
26
  }
27
- function FlaggedPaneProvider({ thread, children }) {
27
+ function CollectionPaneProvider({ collection, title, thread, children, }) {
28
28
  const openThread = useOpenThread();
29
29
  const closeThread = useCloseThread();
30
30
  const goToSection = useGoToSection();
31
31
  const { searchInput } = useMailContext();
32
32
  const threadId = thread?.threadId;
33
33
  const pointedAtMessageId = thread?.messageId;
34
- const { threads } = useStarredThreads();
35
- // The row the starred listing itself holds, preferred because a mutation
34
+ const { threads } = useCollectionThreads(collection);
35
+ // The row the collection listing itself holds, preferred because a mutation
36
36
  // patches it in place. A thread reached from a cold address is in no listing
37
37
  // here and answers for itself — the folder it is filed in is the thread's own
38
- // data, so Starred spanning folders costs the URL nothing.
38
+ // data, so a collection spanning folders costs the URL nothing.
39
39
  const listedThread = useMemo(() => {
40
40
  if (!threadId)
41
41
  return undefined;
@@ -72,7 +72,7 @@ function FlaggedPaneProvider({ thread, children }) {
72
72
  onAfterOptimisticRemove: handleDeselectIfRemoved,
73
73
  });
74
74
  const triage = useTriageContext();
75
- // A Flagged selection spans accounts and mailboxes, so the listings these
75
+ // A collection selection spans accounts and mailboxes, so the listings these
76
76
  // patch are resolved from each message's own mailbox — the open thread's is
77
77
  // only the fallback.
78
78
  const { deleteMessages } = useDeleteMessages({
@@ -144,7 +144,7 @@ function FlaggedPaneProvider({ thread, children }) {
144
144
  },
145
145
  });
146
146
  // The swipe gestures open a whole conversation, so the adjacent row has to
147
- // name its thread. The starred listing is where that is looked up, so a row
147
+ // name its thread. The collection listing is where that is looked up, so a row
148
148
  // it does not hold offers no gesture rather than a tap that goes nowhere.
149
149
  const adjacentThread = useCallback((messageId) => {
150
150
  if (!messageId)
@@ -153,6 +153,8 @@ function FlaggedPaneProvider({ thread, children }) {
153
153
  return row ? { threadId: row.threadId, messageId } : undefined;
154
154
  }, [threads]);
155
155
  const ctx = {
156
+ collection,
157
+ title,
156
158
  selectedMessageId,
157
159
  selectedThread,
158
160
  conversation,
@@ -166,23 +168,23 @@ function FlaggedPaneProvider({ thread, children }) {
166
168
  onDeleteMessages: deleteMessages,
167
169
  handleDeselectIfRemoved,
168
170
  };
169
- return (_jsx(FlaggedPaneCtx.Provider, { value: ctx, children: children }));
171
+ return (_jsx(CollectionPaneCtx.Provider, { value: ctx, children: children }));
170
172
  }
171
173
  /* ------------------------------------------------------------------ */
172
174
  /* Sub-views */
173
175
  /* ------------------------------------------------------------------ */
174
- /** Flat starred list. Mount in the `list` slot of `AppShellSlotted`. */
175
- function FlaggedListSlot() {
176
- const { selectedMessageId, onOpenThread, triage, onDeleteMessages } = useFlaggedPane();
177
- return (_jsx(FlaggedList, { selectedMessageId: selectedMessageId, onOpenThread: onOpenThread, commandsRef: triage.listCommandsRef, onTriageContextChange: triage.onTriageContextChange, onDeleteMessages: onDeleteMessages }));
176
+ /** Flat collection list. Mount in the `list` slot of `AppShellSlotted`. */
177
+ function CollectionListSlot() {
178
+ const { collection, title, selectedMessageId, onOpenThread, triage, onDeleteMessages, } = useCollectionPane();
179
+ return (_jsx(CollectionList, { collection: collection, title: title, selectedMessageId: selectedMessageId, onOpenThread: onOpenThread, commandsRef: triage.listCommandsRef, onTriageContextChange: triage.onTriageContextChange, onDeleteMessages: onDeleteMessages }));
178
180
  }
179
181
  /**
180
182
  * Reading pane: toolbar + ConversationView.
181
183
  * Mount in the `reading` slot of `AppShellSlotted`. Only rendered ≥ 1024px.
182
184
  */
183
- function FlaggedReading() {
185
+ function CollectionReading() {
184
186
  const replyWithText = useReplyWithText();
185
- const { conversation, selectedThread, actions, onReply, handleDeselectIfRemoved, onOpenThread, } = useFlaggedPane();
187
+ const { conversation, selectedThread, actions, onReply, handleDeselectIfRemoved, onOpenThread, } = useCollectionPane();
186
188
  const hasThread = Boolean(conversation);
187
189
  const intelligence = useIntelligenceSurface(conversation?.threadId);
188
190
  return (_jsxs(_Fragment, { children: [_jsxs("section", { className: "flex h-full w-full min-w-0 flex-col bg-canvas", children: [_jsx(MessageToolbar, { hasThread: hasThread, intelligenceOpen: intelligence.isShowing, canToggleIntelligence: intelligence.canToggle, onToggleIntelligence: intelligence.toggle, onReply: onReply ? () => onReply("reply") : undefined, onReplyAll: onReply ? () => onReply("reply-all") : undefined, onForward: onReply ? () => onReply("forward") : undefined, onDelete: hasThread ? actions.deleteThread : undefined, onToggleStar: hasThread ? actions.toggleStar : undefined, isStarred: actions.isStarred, moveContext: hasThread && actions.accountId && actions.mailboxId
@@ -197,29 +199,29 @@ function FlaggedReading() {
197
199
  * Intelligence pane: IntelligencePane for the open thread.
198
200
  * Mount in the `intelligence` slot of `AppShellSlotted`. Only rendered ≥ 1280px.
199
201
  */
200
- function FlaggedIntelligence() {
202
+ function CollectionIntelligence() {
201
203
  const replyWithText = useReplyWithText();
202
- const { selectedThread, handleDeselectIfRemoved, onOpenThread } = useFlaggedPane();
204
+ const { selectedThread, handleDeselectIfRemoved, onOpenThread } = useCollectionPane();
203
205
  const { onToggleIntelligence } = useMailContext();
204
206
  return (_jsx(IntelligencePane, { onClose: onToggleIntelligence, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread }));
205
207
  }
206
208
  /** Phone view: ConversationView when a thread is open, else the flat list. */
207
- function FlaggedPhone() {
209
+ function CollectionPhone() {
208
210
  const replyWithText = useReplyWithText();
209
- const { selectedThread, conversation, onCloseThread, onOpenThread, nextThread, previousThread, handleDeselectIfRemoved, } = useFlaggedPane();
211
+ const { selectedThread, conversation, onCloseThread, onOpenThread, nextThread, previousThread, handleDeselectIfRemoved, } = useCollectionPane();
210
212
  const drawer = useIntelligenceDrawer(conversation?.threadId ?? null);
211
213
  if (conversation) {
212
214
  return (_jsxs(_Fragment, { children: [_jsx(ConversationView, { threadId: conversation.threadId, mailboxId: conversation.mailboxId, subject: conversation.subject, selectedMessageId: conversation.messageId, authenticity: conversation.authenticity, onBack: onCloseThread, onOpenIntelligence: drawer.toggle, onSwipeNext: nextThread ? () => onOpenThread(nextThread) : undefined, onSwipePrevious: previousThread ? () => onOpenThread(previousThread) : undefined, mobileIntelligenceOpen: drawer.isOpen }), _jsx(IntelligenceDrawer, { isOpen: drawer.isOpen, onClose: drawer.close, thread: selectedThread, accountId: selectedThread?.accountId, onAfterOptimisticRemove: handleDeselectIfRemoved, onReplyWithText: replyWithText, onOpenThread: onOpenThread })] }));
213
215
  }
214
- return (_jsx("div", { className: "h-full", children: _jsx(FlaggedListSlot, {}) }));
216
+ return (_jsx("div", { className: "h-full", children: _jsx(CollectionListSlot, {}) }));
215
217
  }
216
218
  /* ------------------------------------------------------------------ */
217
219
  /* Compound component assembly */
218
220
  /* ------------------------------------------------------------------ */
219
- const FlaggedPane = Object.assign(FlaggedPaneProvider, {
220
- List: FlaggedListSlot,
221
- Reading: FlaggedReading,
222
- Intelligence: FlaggedIntelligence,
223
- Phone: FlaggedPhone,
221
+ const CollectionPane = Object.assign(CollectionPaneProvider, {
222
+ List: CollectionListSlot,
223
+ Reading: CollectionReading,
224
+ Intelligence: CollectionIntelligence,
225
+ Phone: CollectionPhone,
224
226
  });
225
- export { FlaggedPane };
227
+ export { CollectionPane };
@@ -4,11 +4,13 @@ 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 { useLabelList } from "../../hooks/useLabels";
7
8
  import { folderFailure } from "../../lib/folder-failure";
8
9
  import { buildMailboxRoleMap, labelForMailbox, shouldShowUnreadBadgeForRole, } from "../../lib/folder-roles";
10
+ import { withoutLabelFolders } from "../../lib/label-folders";
9
11
  import { useMailContext } from "../../lib/mail-context";
10
12
  import { isOutboxListRow } from "../../lib/outbox-status";
11
- import { NavLink, useSelectedNavId } from "../../routing";
13
+ import { labelIdOfNavId, labelNavId, NavLink, useSelectedNavId, } from "../../routing";
12
14
  const startsWithDigit = (str) => /^\d/.test(str);
13
15
  const compareLabelNames = (a, b) => {
14
16
  const aStartsWithDigit = startsWithDigit(a);
@@ -79,17 +81,26 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
79
81
  staleTime: Infinity,
80
82
  })),
81
83
  });
84
+ // The folder tree waits for the labels, so a label folder never shows in it
85
+ // before its label is known. A failed label list leaves the tree whole.
86
+ const { labels, isPending: labelsPending, isError: labelsFailed, } = useLabelList(accounts[0]?.accountId);
87
+ const labelsSettled = !labelsPending || labelsFailed;
88
+ const navLabels = useMemo(() => labels.map((label) => ({
89
+ id: labelNavId(label.labelId),
90
+ name: label.name,
91
+ color: label.color,
92
+ })), [labels]);
82
93
  const { data: outboxResponse } = useQuery(outboxOperationsListOutboxMessagesOptions());
83
94
  const outboxPendingCount = useMemo(() => (outboxResponse?.items ?? []).filter((item) => isOutboxListRow(item.status)).length, [outboxResponse?.items]);
84
95
  const navAccounts = useMemo(() => {
85
96
  return accounts.map((account, i) => {
86
97
  const query = mailboxQueries[i];
87
- const mailboxes = query?.data?.items ?? [];
98
+ const mailboxes = withoutLabelFolders(query?.data?.items ?? [], labels);
88
99
  const roleMap = buildMailboxRoleMap(account.folderAppointments);
89
- const { system, labels } = sortMailboxes(mailboxes, roleMap, translator);
100
+ const { system, labels: folders } = sortMailboxes(mailboxes, roleMap, translator);
90
101
  const status = query?.isError
91
102
  ? "error"
92
- : query?.isLoading
103
+ : query?.isLoading || !labelsSettled
93
104
  ? "loading"
94
105
  : "ready";
95
106
  return {
@@ -102,10 +113,17 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
102
113
  outboxPending: outboxPendingCount,
103
114
  status,
104
115
  onRetry: () => query?.refetch(),
105
- mailboxes: [...system, ...labels].map((mb) => toNavMailbox(mb, roleMap.get(mb.mailboxId), translator)),
116
+ mailboxes: [...system, ...folders].map((mb) => toNavMailbox(mb, roleMap.get(mb.mailboxId), translator)),
106
117
  };
107
118
  });
108
- }, [accounts, mailboxQueries, outboxPendingCount, translator]);
119
+ }, [
120
+ accounts,
121
+ mailboxQueries,
122
+ outboxPendingCount,
123
+ translator,
124
+ labels,
125
+ labelsSettled,
126
+ ]);
109
127
  // Invalidate a mailbox's thread list on navigation so a re-visit always
110
128
  // fetches fresh data (mirrors the retired MailboxItem behaviour).
111
129
  const invalidateMailboxThreads = (mailboxId) => {
@@ -132,6 +150,10 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
132
150
  if (navId === "flagged") {
133
151
  return (_jsx(NavLink, { to: "/mail/flagged", search: { q: undefined }, onClick: () => onClick?.(), className: className, "aria-label": ariaLabel, title: title, children: children }));
134
152
  }
153
+ const labelId = labelIdOfNavId(navId);
154
+ if (labelId) {
155
+ return (_jsx(NavLink, { to: "/mail/label/$labelId", params: { labelId }, search: { q: undefined }, onClick: () => onClick?.(), className: className, "aria-label": ariaLabel, title: title, children: children }));
156
+ }
135
157
  if (navId === "settings") {
136
158
  return (_jsx(NavLink, { to: "/settings/accounts", onClick: () => onClick?.(), className: className, "aria-label": ariaLabel, title: title, children: children }));
137
159
  }
@@ -157,5 +179,5 @@ export function MailSidebarAdapter({ accounts, onMailboxSelect, variant = "deskt
157
179
  onSearchChange("");
158
180
  onMailboxSelect?.();
159
181
  };
160
- return (_jsx(NavSidebar, { accounts: navAccounts, selectedNavId: selectedNavId, onSelectNav: handleSelectNav, linkComponent: linkComponent, variant: variant }));
182
+ return (_jsx(NavSidebar, { accounts: navAccounts, labels: navLabels, selectedNavId: selectedNavId, onSelectNav: handleSelectNav, linkComponent: linkComponent, variant: variant }));
161
183
  }
@@ -1,20 +1,21 @@
1
1
  import type { RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
2
+ import type { ThreadCollection } from "../lib/collection-criteria";
2
3
  import type { ThreadSearchTokenParams } from "../lib/thread-search-tokens";
3
- /** The criteria the Flagged view narrows its listing by, all server-applied. */
4
- export interface StarredCriteria extends ThreadSearchTokenParams {
4
+ /** The criteria a collection view narrows its listing by, all server-applied. */
5
+ export interface CollectionCriteria extends ThreadSearchTokenParams {
5
6
  /**
6
7
  * Free text, matched against subject, From and the body preview over the
7
8
  * whole collection.
8
9
  */
9
10
  query?: string;
10
11
  }
11
- export declare const starredThreadsQueryKey: (criteria?: StarredCriteria) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").UnifiedThreadOperationsListAllThreadsData>, "body" | "headers" | "path" | "query" | "baseUrl"> & {
12
+ export declare const collectionThreadsQueryKey: (collection: ThreadCollection, criteria?: CollectionCriteria) => [Pick<import("@remit/api-http-client").Options<import("@remit/api-http-client").UnifiedThreadOperationsListAllThreadsData>, "body" | "headers" | "path" | "query" | "baseUrl"> & {
12
13
  _id: string;
13
14
  _infinite?: boolean;
14
15
  tags?: ReadonlyArray<string>;
15
16
  }];
16
- interface StarredThreads {
17
- /** Every matching starred thread across the pages loaded so far, newest first. */
17
+ interface CollectionThreads {
18
+ /** Every matching thread across the pages loaded so far, newest first. */
18
19
  threads: RemitImapThreadMessageResponse[];
19
20
  isLoading: boolean;
20
21
  isError: boolean;
@@ -24,9 +25,10 @@ interface StarredThreads {
24
25
  hasNextPage: boolean;
25
26
  isFetchingNextPage: boolean;
26
27
  }
27
- export declare function useStarredThreads(criteria?: StarredCriteria): StarredThreads;
28
+ export declare function useCollectionThreads(collection: ThreadCollection, criteria?: CollectionCriteria): CollectionThreads;
28
29
  /**
29
- * How many of the matching starred messages are unread, counted by the server.
30
+ * How many of the collection's matching messages are unread, counted by the
31
+ * server.
30
32
  *
31
33
  * Its own request, so no cursor enters the key and pressing "load more" cannot
32
34
  * move the number — the count is over the whole collection under the active
@@ -38,5 +40,5 @@ export declare function useStarredThreads(criteria?: StarredCriteria): StarredTh
38
40
  * Undefined until the server answers, and undefined when it cannot. The header
39
41
  * shows no number rather than a made-up one.
40
42
  */
41
- export declare function useStarredUnreadCount(criteria?: StarredCriteria): number | undefined;
43
+ export declare function useCollectionUnreadCount(collection: ThreadCollection, criteria?: CollectionCriteria): number | undefined;
42
44
  export {};
@@ -1,6 +1,7 @@
1
1
  /**
2
- * The starred listing — `GET /threads?starred=true`, served by the `byStarred`
3
- * index — as one hook, so the Starred pane's list and its selection resolve
2
+ * A collection listing — `GET /threads?starred=true`, served by the
3
+ * `byStarred` index, or `GET /threads?labelId=…`, one label's folder in every
4
+ * account — as one hook, so a collection pane's list and its selection resolve
4
5
  * from the same query.
5
6
  *
6
7
  * The two are the same cache entry, not two requests: they share a query key,
@@ -26,23 +27,23 @@ import { unifiedThreadOperationsListAllThreadsQueryKey } from "@remit/api-http-c
26
27
  import { unifiedThreadOperationsListAllThreads } from "@remit/api-http-client/sdk.gen.ts";
27
28
  import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
28
29
  import { useMemo } from "react";
29
- // `starred` and `order` are the view itself, not a criterion, so they are set
30
- // last: no chip can widen the listing past starred mail or reorder it.
31
- const starredQuery = (criteria) => ({
30
+ // The collection and `order` are the view itself, not a criterion, so they are
31
+ // set last: no chip can widen the listing past the collection or reorder it.
32
+ const collectionQuery = (collection, criteria) => ({
32
33
  ...criteria,
33
- starred: true,
34
+ ...collection,
34
35
  order: "desc",
35
36
  });
36
- export const starredThreadsQueryKey = (criteria = {}) => unifiedThreadOperationsListAllThreadsQueryKey({
37
- query: starredQuery(criteria),
37
+ export const collectionThreadsQueryKey = (collection, criteria = {}) => unifiedThreadOperationsListAllThreadsQueryKey({
38
+ query: collectionQuery(collection, criteria),
38
39
  });
39
- export function useStarredThreads(criteria = {}) {
40
+ export function useCollectionThreads(collection, criteria = {}) {
40
41
  const { data, isLoading, isError, error, refetch, fetchNextPage, hasNextPage, isFetchingNextPage, } = useInfiniteQuery({
41
- queryKey: starredThreadsQueryKey(criteria),
42
+ queryKey: collectionThreadsQueryKey(collection, criteria),
42
43
  queryFn: async ({ pageParam }) => {
43
44
  const { data: page } = await unifiedThreadOperationsListAllThreads({
44
45
  query: {
45
- ...starredQuery(criteria),
46
+ ...collectionQuery(collection, criteria),
46
47
  continuationToken: pageParam,
47
48
  },
48
49
  throwOnError: true,
@@ -66,7 +67,8 @@ export function useStarredThreads(criteria = {}) {
66
67
  };
67
68
  }
68
69
  /**
69
- * How many of the matching starred messages are unread, counted by the server.
70
+ * How many of the collection's matching messages are unread, counted by the
71
+ * server.
70
72
  *
71
73
  * Its own request, so no cursor enters the key and pressing "load more" cannot
72
74
  * move the number — the count is over the whole collection under the active
@@ -78,9 +80,9 @@ export function useStarredThreads(criteria = {}) {
78
80
  * Undefined until the server answers, and undefined when it cannot. The header
79
81
  * shows no number rather than a made-up one.
80
82
  */
81
- export function useStarredUnreadCount(criteria = {}) {
83
+ export function useCollectionUnreadCount(collection, criteria = {}) {
82
84
  const query = {
83
- ...starredQuery(criteria),
85
+ ...collectionQuery(collection, criteria),
84
86
  unread: true,
85
87
  count: true,
86
88
  results: false,
@@ -9,6 +9,7 @@ interface UseCurrentMailboxNameOptions {
9
9
  *
10
10
  * Priority:
11
11
  * - `/mail/outbox` → "Outbox"
12
+ * - `/mail/label/$labelId` → the label's name
12
13
  * - `/mail/$mailboxId` → display name from the mailbox query
13
14
  * - everything else (e.g. `/mail` mid-redirect) → `null`
14
15
  *
@@ -4,6 +4,7 @@ import { useCallback } from "react";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import { buildMailboxRoleMap, labelForMailbox } from "../lib/folder-roles";
6
6
  import { useBrowsedList } from "../routing";
7
+ import { useLabelList } from "./useLabels";
7
8
  /**
8
9
  * Resolves a display label for the mailbox or pseudo-mailbox the user is
9
10
  * currently looking at — used by the mobile top bar so it reads e.g.
@@ -11,6 +12,7 @@ import { useBrowsedList } from "../routing";
11
12
  *
12
13
  * Priority:
13
14
  * - `/mail/outbox` → "Outbox"
15
+ * - `/mail/label/$labelId` → the label's name
14
16
  * - `/mail/$mailboxId` → display name from the mailbox query
15
17
  * - everything else (e.g. `/mail` mid-redirect) → `null`
16
18
  *
@@ -19,7 +21,8 @@ import { useBrowsedList } from "../routing";
19
21
  * mounted on `/mail/*`) this is a free lookup.
20
22
  */
21
23
  export const useCurrentMailboxName = ({ accounts, }) => {
22
- const { list, mailboxId } = useBrowsedList();
24
+ const { list, mailboxId, labelId } = useBrowsedList();
25
+ const { labels } = useLabelList(accounts[0]?.accountId);
23
26
  const { t } = useTranslation("mail", { useSuspense: false });
24
27
  const translator = useCallback((key, fallback) => t(key, { defaultValue: fallback }), [t]);
25
28
  const queries = useQueries({
@@ -32,6 +35,8 @@ export const useCurrentMailboxName = ({ accounts, }) => {
32
35
  });
33
36
  if (list === "outbox")
34
37
  return "Outbox";
38
+ if (list === "label")
39
+ return labels.find((label) => label.labelId === labelId)?.name ?? null;
35
40
  if (!mailboxId)
36
41
  return null;
37
42
  for (let i = 0; i < accounts.length; i++) {
@@ -1,4 +1,4 @@
1
- import type { RemitImapLabelColor, RemitImapUpdateLabelInput } from "@remit/api-http-client/types.gen.ts";
1
+ import type { RemitImapLabelColor, RemitImapLabelResponse, RemitImapUpdateLabelInput } from "@remit/api-http-client/types.gen.ts";
2
2
  /**
3
3
  * The query key the label list reads and every mutation invalidates on
4
4
  * success — the same contract `buildFilterListKey` pins for filters, so the
@@ -10,19 +10,20 @@ export declare const buildLabelListKey: (accountId: string) => [Pick<import("@re
10
10
  _infinite?: boolean;
11
11
  tags?: ReadonlyArray<string>;
12
12
  }];
13
- /** List the account's labels. */
13
+ /**
14
+ * The user's labels, every page of them. Labels belong to the user rather than
15
+ * to one account, so any of their accounts answers for all of them.
16
+ */
14
17
  export declare const useLabelList: (accountId: string | undefined) => {
15
- labels: import("@remit/api-http-client").RemitImapLabelResponse[];
18
+ labels: RemitImapLabelResponse[];
19
+ isSuccess: boolean;
16
20
  isPending: boolean;
17
21
  isError: boolean;
18
- error: import("@remit/api-http-client").LabelOperationsListLabelsError | null;
19
- refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<NoInfer<{
20
- continuationToken?: import("@remit/api-http-client").String800;
21
- items: Array<import("@remit/api-http-client").RemitImapLabelResponse>;
22
- }>, import("@remit/api-http-client").LabelOperationsListLabelsError>>;
22
+ error: Error | null;
23
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<NoInfer<RemitImapLabelResponse[]>, Error>>;
23
24
  };
24
25
  export declare const useCreateLabel: (accountId: string | undefined) => {
25
- createLabel: (name: string, color?: RemitImapLabelColor) => Promise<import("@remit/api-http-client").RemitImapLabelResponse>;
26
+ createLabel: (name: string, color?: RemitImapLabelColor) => Promise<RemitImapLabelResponse>;
26
27
  isPending: boolean;
27
28
  isError: boolean;
28
29
  error: import("@remit/api-http-client").ApiError | null;