@remit/web-client 0.0.145 → 0.0.147
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/package.json +1 -1
- package/src/components/compose/ComposeForm.tsx +169 -120
- package/src/components/compose/ComposeSmtpMissingBanner.tsx +4 -0
- package/src/components/compose/mobile-header-stays-expanded.render.test.ts +182 -0
- package/src/components/layout/ComposeFab.tsx +7 -3
- package/src/components/mail/BriefPane.tsx +92 -122
- package/src/components/mail/DailyBrief.tsx +28 -26
- package/src/components/mail/MailSidebarAdapter.tsx +2 -5
- package/src/hooks/search-mirror-detail.render.test.ts +205 -0
- package/src/hooks/useSearchMirror.ts +30 -22
- package/src/hooks/useSearchScope.ts +1 -1
- package/src/hooks/useThreadRow.ts +35 -0
- package/src/lib/mail-route.test.ts +26 -0
- package/src/lib/mail-route.ts +13 -0
- package/src/lib/mail-search.ts +7 -7
- package/src/routeTree.gen.ts +71 -0
- package/src/routes/mail/brief/$threadId/$messageId.tsx +19 -0
- package/src/routes/mail/brief/$threadId/index.tsx +14 -0
- package/src/routes/mail/brief/$threadId.tsx +16 -0
- package/src/routes/mail/brief.tsx +7 -4
- package/src/routing/brief-thread.ts +47 -0
- package/src/routing/index.ts +5 -0
|
@@ -28,14 +28,19 @@ export type SearchMirrorTarget =
|
|
|
28
28
|
* flight and replacing the entry the reader had just pushed. They would click
|
|
29
29
|
* Inbox and land back on the brief.
|
|
30
30
|
*
|
|
31
|
-
* When a query *goes* active it also
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
31
|
+
* When a query *goes* active it also closes the reading pane (#539): an open
|
|
32
|
+
* message from the pre-search list is not meaningful in the search result set.
|
|
33
|
+
* The close is a navigation to the list route, which unmatches the thread that
|
|
34
|
+
* was open under it — plus, until the remaining lists move their selection into
|
|
35
|
+
* the path, dropping the params they still read it from. Any other write keeps
|
|
36
|
+
* the address it found: mirroring a query the reader is editing, or clearing
|
|
37
|
+
* one, must not shut the conversation they are reading.
|
|
38
|
+
*
|
|
39
|
+
* Only on that transition, though — tapping a search result commits the same `q`
|
|
40
|
+
* with the open thread, so when the URL already says the query the conversation
|
|
41
|
+
* was opened under it (not a pre-search leftover) and must survive. The close
|
|
42
|
+
* otherwise raced the tap: the row shows before the debounce settles, so this
|
|
43
|
+
* mirror can land just after the open and undo it.
|
|
39
44
|
*/
|
|
40
45
|
export function useSearchMirror(target: SearchMirrorTarget): void {
|
|
41
46
|
const navigate = useNavigate();
|
|
@@ -61,20 +66,23 @@ export function useSearchMirror(target: SearchMirrorTarget): void {
|
|
|
61
66
|
listPath,
|
|
62
67
|
});
|
|
63
68
|
if (!mayWrite) return;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
const queryGoesActive =
|
|
70
|
+
Boolean(committedQuery) && urlQueryRef.current !== committedQuery;
|
|
71
|
+
const search = (prev: Record<string, unknown>) => ({
|
|
72
|
+
...prev,
|
|
73
|
+
q: committedQuery || undefined,
|
|
74
|
+
...(queryGoesActive
|
|
75
|
+
? {
|
|
76
|
+
selectedMessageId: undefined,
|
|
77
|
+
selectedThreadId: undefined,
|
|
78
|
+
selectedMailboxId: undefined,
|
|
79
|
+
}
|
|
80
|
+
: {}),
|
|
81
|
+
});
|
|
82
|
+
if (!queryGoesActive) {
|
|
83
|
+
navigate({ to: ".", search, replace: true });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
78
86
|
if (to === "/mail/$mailboxId") {
|
|
79
87
|
if (!mailboxId) return;
|
|
80
88
|
navigate({ to, params: { mailboxId }, search, replace: true });
|
|
@@ -39,7 +39,7 @@ export function useSearchScope(accounts: RemitImapAccountResponse[]): {
|
|
|
39
39
|
if (chipId !== SEARCH_SCOPE_CHIP_ID) return;
|
|
40
40
|
navigate({
|
|
41
41
|
to: "/mail/brief",
|
|
42
|
-
search: { q: searchInput || undefined
|
|
42
|
+
search: { q: searchInput || undefined },
|
|
43
43
|
});
|
|
44
44
|
},
|
|
45
45
|
[navigate, searchInput],
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { threadDetailOperationsListThreadMessagesOptions } from "@remit/api-http-client/@tanstack/react-query.gen.ts";
|
|
2
|
+
import type { RemitImapThreadMessageResponse } from "@remit/api-http-client/types.gen.ts";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A thread's own row for the message the reader pointed at.
|
|
7
|
+
*
|
|
8
|
+
* This is how a conversation answers for itself when no list holds it — a
|
|
9
|
+
* cross-folder search hit, or an address pasted into a fresh tab.
|
|
10
|
+
* `GET /threads/{threadId}/messages` returns the same row shape a listing does,
|
|
11
|
+
* `mailboxId` included, so the thread id is the whole address even though the
|
|
12
|
+
* mail is filed in some folder. The reading pane already makes that request, so
|
|
13
|
+
* this resolves off the same cache entry rather than a round trip of its own.
|
|
14
|
+
*
|
|
15
|
+
* A thread spans folders — the reader's own reply sits in Sent — so `messageId`
|
|
16
|
+
* picks the row they pointed at. With none, the newest message answers.
|
|
17
|
+
*/
|
|
18
|
+
export const useThreadRow = (
|
|
19
|
+
threadId: string | undefined,
|
|
20
|
+
messageId: string | undefined,
|
|
21
|
+
): RemitImapThreadMessageResponse | undefined => {
|
|
22
|
+
const { data } = useQuery({
|
|
23
|
+
...threadDetailOperationsListThreadMessagesOptions({
|
|
24
|
+
path: { threadId: threadId ?? "" },
|
|
25
|
+
}),
|
|
26
|
+
enabled: Boolean(threadId),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const items = data?.items ?? [];
|
|
30
|
+
const pointedAt = messageId
|
|
31
|
+
? items.find((item) => item.messageId === messageId)
|
|
32
|
+
: undefined;
|
|
33
|
+
const newest = items.length > 0 ? items[items.length - 1] : undefined;
|
|
34
|
+
return pointedAt ?? newest;
|
|
35
|
+
};
|
|
@@ -20,6 +20,7 @@ import assert from "node:assert/strict";
|
|
|
20
20
|
import { describe, it } from "node:test";
|
|
21
21
|
import {
|
|
22
22
|
locationIsOnList,
|
|
23
|
+
locationOpensDetail,
|
|
23
24
|
MAIL_BRIEF_ROUTE_ID,
|
|
24
25
|
MAIL_FLAGGED_ROUTE_ID,
|
|
25
26
|
MAIL_MAILBOX_ROUTE_ID,
|
|
@@ -178,3 +179,28 @@ describe("locationIsOnList", () => {
|
|
|
178
179
|
assert.equal(locationIsOnList("/mail/outbox-2024", "/mail/outbox"), false);
|
|
179
180
|
});
|
|
180
181
|
});
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* What "a thread is open" used to be asked of the query. Everything sharing the
|
|
185
|
+
* single pane with the conversation reads it from the address instead.
|
|
186
|
+
*/
|
|
187
|
+
describe("locationOpensDetail", () => {
|
|
188
|
+
it("is true for a thread and for the message inside it", () => {
|
|
189
|
+
assert.equal(locationOpensDetail("/mail/brief/thread-1"), true);
|
|
190
|
+
assert.equal(locationOpensDetail("/mail/brief/thread-1/message-1"), true);
|
|
191
|
+
assert.equal(locationOpensDetail("/mail/inbox-1/thread-1"), true);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("is false on a bare list, trailing slash and query included", () => {
|
|
195
|
+
assert.equal(locationOpensDetail("/mail/brief"), false);
|
|
196
|
+
assert.equal(locationOpensDetail("/mail/brief/"), false);
|
|
197
|
+
assert.equal(locationOpensDetail("/mail/brief?q=invoice"), false);
|
|
198
|
+
assert.equal(locationOpensDetail("/mail/inbox-1"), false);
|
|
199
|
+
assert.equal(locationOpensDetail("/mail"), false);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("is false outside the mail shell", () => {
|
|
203
|
+
assert.equal(locationOpensDetail("/settings/accounts"), false);
|
|
204
|
+
assert.equal(locationOpensDetail("/onboarding"), false);
|
|
205
|
+
});
|
|
206
|
+
});
|
package/src/lib/mail-route.ts
CHANGED
|
@@ -92,3 +92,16 @@ export function locationIsOnList(pathname: string, listPath: string): boolean {
|
|
|
92
92
|
if (pathname === listPath) return true;
|
|
93
93
|
return pathname.startsWith(`${listPath}/`);
|
|
94
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Whether the address names something the list has open below it — a thread, a
|
|
98
|
+
* message. A list on its own, and its bare reading pane, do not.
|
|
99
|
+
*
|
|
100
|
+
* Answers what an open thread used to be asked of the query. Anything sharing
|
|
101
|
+
* the single pane with the conversation reads it from here rather than keeping a
|
|
102
|
+
* second opinion about what is on screen.
|
|
103
|
+
*/
|
|
104
|
+
export function locationOpensDetail(pathname: string): boolean {
|
|
105
|
+
const segments = pathname.split(/[?#]/)[0].split("/").filter(Boolean);
|
|
106
|
+
return segments[0] === "mail" && segments.length > 2;
|
|
107
|
+
}
|
package/src/lib/mail-search.ts
CHANGED
|
@@ -12,13 +12,13 @@ import { z } from "zod";
|
|
|
12
12
|
/** What every list carries, whatever else it carries. */
|
|
13
13
|
const listSearch = z.object({ q: z.string().optional() });
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
15
|
+
/**
|
|
16
|
+
* The brief's open thread and the message inside it are path segments
|
|
17
|
+
* (`/mail/brief/<thread>/<message>`), so the query carries nothing but the
|
|
18
|
+
* search. An old link's selection params are dropped here, which is what
|
|
19
|
+
* "tolerated and ignored" means until the other three lists follow.
|
|
20
|
+
*/
|
|
21
|
+
export const briefSearchSchema = listSearch.extend({});
|
|
22
22
|
|
|
23
23
|
export const flaggedSearchSchema = listSearch.extend({
|
|
24
24
|
selectedMessageId: z.string().optional(),
|
package/src/routeTree.gen.ts
CHANGED
|
@@ -29,8 +29,11 @@ import { Route as SettingsSendersRouteImport } from './routes/settings/senders'
|
|
|
29
29
|
import { Route as SettingsSuggestedVipsRouteImport } from './routes/settings/suggested-vips'
|
|
30
30
|
import { Route as MailMailboxIdIndexRouteImport } from './routes/mail/$mailboxId/index'
|
|
31
31
|
import { Route as MailBriefIndexRouteImport } from './routes/mail/brief/index'
|
|
32
|
+
import { Route as MailBriefThreadIdRouteImport } from './routes/mail/brief/$threadId'
|
|
32
33
|
import { Route as MailFlaggedIndexRouteImport } from './routes/mail/flagged/index'
|
|
33
34
|
import { Route as MailOutboxIndexRouteImport } from './routes/mail/outbox/index'
|
|
35
|
+
import { Route as MailBriefThreadIdIndexRouteImport } from './routes/mail/brief/$threadId/index'
|
|
36
|
+
import { Route as MailBriefThreadIdMessageIdRouteImport } from './routes/mail/brief/$threadId/$messageId'
|
|
34
37
|
|
|
35
38
|
const IndexRoute = IndexRouteImport.update({
|
|
36
39
|
id: '/',
|
|
@@ -132,6 +135,11 @@ const MailBriefIndexRoute = MailBriefIndexRouteImport.update({
|
|
|
132
135
|
path: '/',
|
|
133
136
|
getParentRoute: () => MailBriefRoute,
|
|
134
137
|
} as any)
|
|
138
|
+
const MailBriefThreadIdRoute = MailBriefThreadIdRouteImport.update({
|
|
139
|
+
id: '/$threadId',
|
|
140
|
+
path: '/$threadId',
|
|
141
|
+
getParentRoute: () => MailBriefRoute,
|
|
142
|
+
} as any)
|
|
135
143
|
const MailFlaggedIndexRoute = MailFlaggedIndexRouteImport.update({
|
|
136
144
|
id: '/',
|
|
137
145
|
path: '/',
|
|
@@ -142,6 +150,17 @@ const MailOutboxIndexRoute = MailOutboxIndexRouteImport.update({
|
|
|
142
150
|
path: '/',
|
|
143
151
|
getParentRoute: () => MailOutboxRoute,
|
|
144
152
|
} as any)
|
|
153
|
+
const MailBriefThreadIdIndexRoute = MailBriefThreadIdIndexRouteImport.update({
|
|
154
|
+
id: '/',
|
|
155
|
+
path: '/',
|
|
156
|
+
getParentRoute: () => MailBriefThreadIdRoute,
|
|
157
|
+
} as any)
|
|
158
|
+
const MailBriefThreadIdMessageIdRoute =
|
|
159
|
+
MailBriefThreadIdMessageIdRouteImport.update({
|
|
160
|
+
id: '/$messageId',
|
|
161
|
+
path: '/$messageId',
|
|
162
|
+
getParentRoute: () => MailBriefThreadIdRoute,
|
|
163
|
+
} as any)
|
|
145
164
|
|
|
146
165
|
export interface FileRoutesByFullPath {
|
|
147
166
|
'/': typeof IndexRoute
|
|
@@ -162,10 +181,13 @@ export interface FileRoutesByFullPath {
|
|
|
162
181
|
'/settings/suggested-vips': typeof SettingsSuggestedVipsRoute
|
|
163
182
|
'/mail/': typeof MailIndexRoute
|
|
164
183
|
'/settings/': typeof SettingsIndexRoute
|
|
184
|
+
'/mail/brief/$threadId': typeof MailBriefThreadIdRouteWithChildren
|
|
165
185
|
'/mail/$mailboxId/': typeof MailMailboxIdIndexRoute
|
|
166
186
|
'/mail/brief/': typeof MailBriefIndexRoute
|
|
167
187
|
'/mail/flagged/': typeof MailFlaggedIndexRoute
|
|
168
188
|
'/mail/outbox/': typeof MailOutboxIndexRoute
|
|
189
|
+
'/mail/brief/$threadId/$messageId': typeof MailBriefThreadIdMessageIdRoute
|
|
190
|
+
'/mail/brief/$threadId/': typeof MailBriefThreadIdIndexRoute
|
|
169
191
|
}
|
|
170
192
|
export interface FileRoutesByTo {
|
|
171
193
|
'/': typeof IndexRoute
|
|
@@ -184,6 +206,8 @@ export interface FileRoutesByTo {
|
|
|
184
206
|
'/mail/brief': typeof MailBriefIndexRoute
|
|
185
207
|
'/mail/flagged': typeof MailFlaggedIndexRoute
|
|
186
208
|
'/mail/outbox': typeof MailOutboxIndexRoute
|
|
209
|
+
'/mail/brief/$threadId/$messageId': typeof MailBriefThreadIdMessageIdRoute
|
|
210
|
+
'/mail/brief/$threadId': typeof MailBriefThreadIdIndexRoute
|
|
187
211
|
}
|
|
188
212
|
export interface FileRoutesById {
|
|
189
213
|
__root__: typeof rootRouteImport
|
|
@@ -205,10 +229,13 @@ export interface FileRoutesById {
|
|
|
205
229
|
'/settings/suggested-vips': typeof SettingsSuggestedVipsRoute
|
|
206
230
|
'/mail/': typeof MailIndexRoute
|
|
207
231
|
'/settings/': typeof SettingsIndexRoute
|
|
232
|
+
'/mail/brief/$threadId': typeof MailBriefThreadIdRouteWithChildren
|
|
208
233
|
'/mail/$mailboxId/': typeof MailMailboxIdIndexRoute
|
|
209
234
|
'/mail/brief/': typeof MailBriefIndexRoute
|
|
210
235
|
'/mail/flagged/': typeof MailFlaggedIndexRoute
|
|
211
236
|
'/mail/outbox/': typeof MailOutboxIndexRoute
|
|
237
|
+
'/mail/brief/$threadId/$messageId': typeof MailBriefThreadIdMessageIdRoute
|
|
238
|
+
'/mail/brief/$threadId/': typeof MailBriefThreadIdIndexRoute
|
|
212
239
|
}
|
|
213
240
|
export interface FileRouteTypes {
|
|
214
241
|
fileRoutesByFullPath: FileRoutesByFullPath
|
|
@@ -231,10 +258,13 @@ export interface FileRouteTypes {
|
|
|
231
258
|
| '/settings/suggested-vips'
|
|
232
259
|
| '/mail/'
|
|
233
260
|
| '/settings/'
|
|
261
|
+
| '/mail/brief/$threadId'
|
|
234
262
|
| '/mail/$mailboxId/'
|
|
235
263
|
| '/mail/brief/'
|
|
236
264
|
| '/mail/flagged/'
|
|
237
265
|
| '/mail/outbox/'
|
|
266
|
+
| '/mail/brief/$threadId/$messageId'
|
|
267
|
+
| '/mail/brief/$threadId/'
|
|
238
268
|
fileRoutesByTo: FileRoutesByTo
|
|
239
269
|
to:
|
|
240
270
|
| '/'
|
|
@@ -253,6 +283,8 @@ export interface FileRouteTypes {
|
|
|
253
283
|
| '/mail/brief'
|
|
254
284
|
| '/mail/flagged'
|
|
255
285
|
| '/mail/outbox'
|
|
286
|
+
| '/mail/brief/$threadId/$messageId'
|
|
287
|
+
| '/mail/brief/$threadId'
|
|
256
288
|
id:
|
|
257
289
|
| '__root__'
|
|
258
290
|
| '/'
|
|
@@ -273,10 +305,13 @@ export interface FileRouteTypes {
|
|
|
273
305
|
| '/settings/suggested-vips'
|
|
274
306
|
| '/mail/'
|
|
275
307
|
| '/settings/'
|
|
308
|
+
| '/mail/brief/$threadId'
|
|
276
309
|
| '/mail/$mailboxId/'
|
|
277
310
|
| '/mail/brief/'
|
|
278
311
|
| '/mail/flagged/'
|
|
279
312
|
| '/mail/outbox/'
|
|
313
|
+
| '/mail/brief/$threadId/$messageId'
|
|
314
|
+
| '/mail/brief/$threadId/'
|
|
280
315
|
fileRoutesById: FileRoutesById
|
|
281
316
|
}
|
|
282
317
|
export interface RootRouteChildren {
|
|
@@ -428,6 +463,13 @@ declare module '@tanstack/react-router' {
|
|
|
428
463
|
preLoaderRoute: typeof MailBriefIndexRouteImport
|
|
429
464
|
parentRoute: typeof MailBriefRoute
|
|
430
465
|
}
|
|
466
|
+
'/mail/brief/$threadId': {
|
|
467
|
+
id: '/mail/brief/$threadId'
|
|
468
|
+
path: '/$threadId'
|
|
469
|
+
fullPath: '/mail/brief/$threadId'
|
|
470
|
+
preLoaderRoute: typeof MailBriefThreadIdRouteImport
|
|
471
|
+
parentRoute: typeof MailBriefRoute
|
|
472
|
+
}
|
|
431
473
|
'/mail/flagged/': {
|
|
432
474
|
id: '/mail/flagged/'
|
|
433
475
|
path: '/'
|
|
@@ -442,6 +484,20 @@ declare module '@tanstack/react-router' {
|
|
|
442
484
|
preLoaderRoute: typeof MailOutboxIndexRouteImport
|
|
443
485
|
parentRoute: typeof MailOutboxRoute
|
|
444
486
|
}
|
|
487
|
+
'/mail/brief/$threadId/': {
|
|
488
|
+
id: '/mail/brief/$threadId/'
|
|
489
|
+
path: '/'
|
|
490
|
+
fullPath: '/mail/brief/$threadId/'
|
|
491
|
+
preLoaderRoute: typeof MailBriefThreadIdIndexRouteImport
|
|
492
|
+
parentRoute: typeof MailBriefThreadIdRoute
|
|
493
|
+
}
|
|
494
|
+
'/mail/brief/$threadId/$messageId': {
|
|
495
|
+
id: '/mail/brief/$threadId/$messageId'
|
|
496
|
+
path: '/$messageId'
|
|
497
|
+
fullPath: '/mail/brief/$threadId/$messageId'
|
|
498
|
+
preLoaderRoute: typeof MailBriefThreadIdMessageIdRouteImport
|
|
499
|
+
parentRoute: typeof MailBriefThreadIdRoute
|
|
500
|
+
}
|
|
445
501
|
}
|
|
446
502
|
}
|
|
447
503
|
|
|
@@ -457,11 +513,26 @@ const MailMailboxIdRouteWithChildren = MailMailboxIdRoute._addFileChildren(
|
|
|
457
513
|
MailMailboxIdRouteChildren,
|
|
458
514
|
)
|
|
459
515
|
|
|
516
|
+
interface MailBriefThreadIdRouteChildren {
|
|
517
|
+
MailBriefThreadIdMessageIdRoute: typeof MailBriefThreadIdMessageIdRoute
|
|
518
|
+
MailBriefThreadIdIndexRoute: typeof MailBriefThreadIdIndexRoute
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const MailBriefThreadIdRouteChildren: MailBriefThreadIdRouteChildren = {
|
|
522
|
+
MailBriefThreadIdMessageIdRoute: MailBriefThreadIdMessageIdRoute,
|
|
523
|
+
MailBriefThreadIdIndexRoute: MailBriefThreadIdIndexRoute,
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const MailBriefThreadIdRouteWithChildren =
|
|
527
|
+
MailBriefThreadIdRoute._addFileChildren(MailBriefThreadIdRouteChildren)
|
|
528
|
+
|
|
460
529
|
interface MailBriefRouteChildren {
|
|
530
|
+
MailBriefThreadIdRoute: typeof MailBriefThreadIdRouteWithChildren
|
|
461
531
|
MailBriefIndexRoute: typeof MailBriefIndexRoute
|
|
462
532
|
}
|
|
463
533
|
|
|
464
534
|
const MailBriefRouteChildren: MailBriefRouteChildren = {
|
|
535
|
+
MailBriefThreadIdRoute: MailBriefThreadIdRouteWithChildren,
|
|
465
536
|
MailBriefIndexRoute: MailBriefIndexRoute,
|
|
466
537
|
}
|
|
467
538
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /mail/brief/$threadId/$messageId — the same conversation, with one of its
|
|
3
|
+
* messages expanded and scrolled to.
|
|
4
|
+
*
|
|
5
|
+
* A message is not addressable on its own: `GET /messages/{messageId}` answers
|
|
6
|
+
* with no thread, so the pane has nothing to fetch by. The segment names which
|
|
7
|
+
* message inside the thread the reader pointed at, and the surface it renders is
|
|
8
|
+
* the thread's.
|
|
9
|
+
*/
|
|
10
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
11
|
+
import { BriefPane } from "@/components/mail/BriefPane";
|
|
12
|
+
|
|
13
|
+
function BriefMessagePane() {
|
|
14
|
+
return <BriefPane.Reading />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const Route = createFileRoute("/mail/brief/$threadId/$messageId")({
|
|
18
|
+
component: BriefMessagePane,
|
|
19
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The thread with no message named. The pane opens on the newest message, the
|
|
3
|
+
* same as for a thread whose row the reader never pointed at.
|
|
4
|
+
*/
|
|
5
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
6
|
+
import { BriefPane } from "@/components/mail/BriefPane";
|
|
7
|
+
|
|
8
|
+
function BriefThreadPane() {
|
|
9
|
+
return <BriefPane.Reading />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Route = createFileRoute("/mail/brief/$threadId/")({
|
|
13
|
+
component: BriefThreadPane,
|
|
14
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /mail/brief/$threadId — a conversation open in the brief's reading pane.
|
|
3
|
+
*
|
|
4
|
+
* The brief is cross-mailbox, and the thread is still the whole address: the
|
|
5
|
+
* folder its mail is filed in comes from the thread's own data, since
|
|
6
|
+
* `GET /threads/{threadId}/messages` answers with rows that each name their
|
|
7
|
+
* mailbox. A segment for the folder would be a second owner of a fact the
|
|
8
|
+
* thread already carries.
|
|
9
|
+
*
|
|
10
|
+
* A layout, because the message segment nests under it.
|
|
11
|
+
*/
|
|
12
|
+
import { createFileRoute, Outlet } from "@tanstack/react-router";
|
|
13
|
+
|
|
14
|
+
export const Route = createFileRoute("/mail/brief/$threadId")({
|
|
15
|
+
component: Outlet,
|
|
16
|
+
});
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The route mounts the list and the shell around it, and the reading pane is
|
|
5
5
|
* the `Outlet`, so what the pane shows is whatever route is matched under this
|
|
6
|
-
* one rather than a decision made somewhere above.
|
|
6
|
+
* one rather than a decision made somewhere above. The open thread and the
|
|
7
|
+
* message inside it are the segments below, which is why nothing here reads a
|
|
8
|
+
* selection out of the query.
|
|
7
9
|
*/
|
|
8
10
|
import {
|
|
9
11
|
createFileRoute,
|
|
@@ -15,6 +17,7 @@ import { BriefPane } from "@/components/mail/BriefPane";
|
|
|
15
17
|
import { ErrorState } from "@/components/ui/ErrorState";
|
|
16
18
|
import { useSearchMirror } from "@/hooks/useSearchMirror";
|
|
17
19
|
import { briefSearchSchema } from "@/lib/mail-search";
|
|
20
|
+
import { useBriefThreadPath } from "@/routing";
|
|
18
21
|
|
|
19
22
|
const BriefError = ({ error, reset }: ErrorComponentProps) => (
|
|
20
23
|
<div className="flex h-full items-center justify-center bg-canvas p-4">
|
|
@@ -27,17 +30,17 @@ const BriefError = ({ error, reset }: ErrorComponentProps) => (
|
|
|
27
30
|
);
|
|
28
31
|
|
|
29
32
|
function BriefLayout() {
|
|
30
|
-
const
|
|
33
|
+
const thread = useBriefThreadPath();
|
|
31
34
|
useSearchMirror({ to: "/mail/brief" });
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
|
-
<BriefPane
|
|
37
|
+
<BriefPane thread={thread}>
|
|
35
38
|
<MailShell
|
|
36
39
|
phone={<BriefPane.Phone />}
|
|
37
40
|
list={<BriefPane.List />}
|
|
38
41
|
reading={<Outlet />}
|
|
39
42
|
intelligence={<BriefPane.Intelligence />}
|
|
40
|
-
hasThread={Boolean(
|
|
43
|
+
hasThread={Boolean(thread)}
|
|
41
44
|
/>
|
|
42
45
|
</BriefPane>
|
|
43
46
|
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useParams } from "@tanstack/react-router";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
/** The conversation the brief has open, as the address states it. */
|
|
5
|
+
export interface BriefThreadPath {
|
|
6
|
+
threadId: string;
|
|
7
|
+
/**
|
|
8
|
+
* Which message inside the thread is expanded and scrolled to. Absent on a
|
|
9
|
+
* bare thread address, where the newest message answers for the conversation.
|
|
10
|
+
*/
|
|
11
|
+
messageId: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A conversation to open. The thread is what the pane fetches by; the message is
|
|
16
|
+
* the row the reader pointed at, so a list always knows both.
|
|
17
|
+
*/
|
|
18
|
+
export interface BriefThreadTarget {
|
|
19
|
+
threadId: string;
|
|
20
|
+
messageId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The thread the brief has open, read off the path.
|
|
25
|
+
*
|
|
26
|
+
* The thread is a child route of the list, and the list layout mounts the pane
|
|
27
|
+
* above the `Outlet` — so it asks the router which of its children matched
|
|
28
|
+
* rather than reading a param it does not own. Each `from` names a real route,
|
|
29
|
+
* so a segment that does not exist fails to compile.
|
|
30
|
+
*/
|
|
31
|
+
export function useBriefThreadPath(): BriefThreadPath | undefined {
|
|
32
|
+
const thread = useParams({
|
|
33
|
+
from: "/mail/brief/$threadId",
|
|
34
|
+
shouldThrow: false,
|
|
35
|
+
});
|
|
36
|
+
const message = useParams({
|
|
37
|
+
from: "/mail/brief/$threadId/$messageId",
|
|
38
|
+
shouldThrow: false,
|
|
39
|
+
});
|
|
40
|
+
const threadId = thread?.threadId;
|
|
41
|
+
const messageId = message?.messageId;
|
|
42
|
+
|
|
43
|
+
return useMemo(
|
|
44
|
+
() => (threadId ? { threadId, messageId } : undefined),
|
|
45
|
+
[threadId, messageId],
|
|
46
|
+
);
|
|
47
|
+
}
|