@rapidmx/web-client 0.9.0 → 0.10.0
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/README.md +192 -88
- package/apps/shared/auth/accountUrl.ts +9 -0
- package/apps/shared/auth/adminAccess.ts +99 -0
- package/apps/shared/components/admin/settings/DomainDnsSetup.tsx +2 -1
- package/apps/shared/components/calendar/layout/CalendarShell.tsx +8 -2
- package/apps/shared/components/contacts/ContactsToolbar.tsx +125 -115
- package/apps/shared/components/contacts/layout/ContactsShell.tsx +15 -3
- package/apps/shared/components/layout/AppShell.tsx +411 -288
- package/apps/shared/components/layout/KeyEnrollmentGate.tsx +398 -389
- package/apps/shared/components/layout/MailboxProvisioning.tsx +168 -164
- package/apps/shared/components/layout/UserMenu.tsx +303 -185
- package/apps/shared/components/mail/ConversationList.tsx +269 -262
- package/apps/shared/components/mail/ConversationThreadPane.tsx +475 -434
- package/apps/shared/components/mail/LazyReadingPane.tsx +115 -0
- package/apps/shared/components/mail/MailSelectionBar.tsx +235 -222
- package/apps/shared/components/mail/MessageDetailPane.tsx +1458 -1387
- package/apps/shared/components/mail/NewMailToasts.tsx +141 -0
- package/apps/shared/components/mail/compose/ComposeContext.tsx +279 -160
- package/apps/shared/components/mail/compose/ComposeToolbar.tsx +422 -418
- package/apps/shared/components/mail/compose/ComposeWindow.tsx +1842 -1736
- package/apps/shared/components/mail/compose/ComposeWindowPlaceholder.tsx +111 -0
- package/apps/shared/components/mail/compose/RichTextEditor.tsx +147 -118
- package/apps/shared/components/mail/compose/composePerf.ts +46 -0
- package/apps/shared/components/mail/compose/quotedBody.ts +161 -100
- package/apps/shared/components/mail/layout/MailShell.tsx +476 -472
- package/apps/shared/components/mail/unreadStyle.tsx +75 -0
- package/apps/shared/components/settings/layout/SettingsShell.tsx +252 -240
- package/apps/shared/components/tasks/layout/TasksShell.tsx +15 -3
- package/apps/shared/keyboard/GlobalShortcuts.tsx +51 -0
- package/apps/shared/keyboard/ShortcutProvider.tsx +62 -0
- package/apps/shared/keyboard/ShortcutsDialog.tsx +84 -0
- package/apps/shared/keyboard/dispatch.ts +124 -0
- package/apps/shared/keyboard/format.ts +89 -0
- package/apps/shared/keyboard/keymap.ts +114 -0
- package/apps/shared/keyboard/match.ts +44 -0
- package/apps/shared/keyboard/parse.ts +136 -0
- package/apps/shared/keyboard/platform.ts +34 -0
- package/apps/shared/keyboard/registry.ts +65 -0
- package/apps/shared/keyboard/targets.ts +79 -0
- package/apps/shared/keyboard/useShortcut.ts +50 -0
- package/apps/shared/keyboard/useShortcutProps.ts +17 -0
- package/apps/shared/mail/folderCounts.ts +302 -0
- package/apps/shared/mail/listSnapshots.ts +87 -0
- package/apps/shared/mail/messageReadState.ts +85 -0
- package/apps/shared/mail/newMailNotifications.ts +183 -0
- package/apps/shared/mail/useMailConnection.ts +150 -0
- package/apps/shared/mail/useMailLiveUpdates.ts +232 -224
- package/apps/shared/mail/useMarkMessageRead.ts +47 -0
- package/apps/shared/mail/useNewMailNotifications.ts +163 -0
- package/apps/shared/mail/useUnreadTitle.ts +42 -0
- package/apps/shared/navigation/AppRouter.tsx +300 -0
- package/apps/shared/navigation/appHrefs.ts +23 -0
- package/apps/shared/navigation/frameContext.tsx +35 -0
- package/apps/shared/navigation/idle.ts +45 -0
- package/apps/shared/navigation/routerContext.tsx +83 -0
- package/apps/shared/navigation/routes.ts +72 -0
- package/apps/shared/search/LocalIndexLifecycle.tsx +114 -98
- package/apps/shared/styles/app.css +28 -10
- package/apps/www/_routedPage.tsx +24 -0
- package/apps/www/_routes.ts +35 -0
- package/apps/www/calendar/index.tsx +55 -19
- package/apps/www/contacts/[uid].tsx +112 -107
- package/apps/www/contacts/index.tsx +584 -567
- package/apps/www/index.tsx +2280 -1917
- package/apps/www/messages/[uid].tsx +106 -101
- package/apps/www/settings/auto-reply/index.tsx +4 -1
- package/apps/www/settings/encryption/index.tsx +1252 -1249
- package/apps/www/settings/filters/[uid].tsx +4 -1
- package/apps/www/settings/filters/index.tsx +102 -99
- package/apps/www/settings/filters/new/index.tsx +138 -133
- package/apps/www/settings/labels/index.tsx +204 -201
- package/apps/www/settings/privacy/index.tsx +4 -1
- package/apps/www/settings/read-receipts/index.tsx +4 -1
- package/apps/www/settings/sharing/index.tsx +277 -274
- package/apps/www/settings/signatures/[uid].tsx +170 -167
- package/apps/www/settings/signatures/index.tsx +88 -85
- package/apps/www/settings/signatures/new/index.tsx +134 -129
- package/apps/www/tasks/index.tsx +18 -2
- package/dist/apps/shared/auth/accountUrl.d.ts +2 -0
- package/dist/apps/shared/auth/accountUrl.js +8 -0
- package/dist/apps/shared/auth/adminAccess.d.ts +30 -0
- package/dist/apps/shared/auth/adminAccess.js +89 -0
- package/dist/apps/shared/components/admin/settings/DomainDnsSetup.js +1 -1
- package/dist/apps/shared/components/calendar/layout/CalendarShell.d.ts +1 -1
- package/dist/apps/shared/components/calendar/layout/CalendarShell.js +8 -4
- package/dist/apps/shared/components/contacts/ContactsToolbar.d.ts +3 -1
- package/dist/apps/shared/components/contacts/ContactsToolbar.js +7 -4
- package/dist/apps/shared/components/contacts/layout/ContactsShell.d.ts +1 -1
- package/dist/apps/shared/components/contacts/layout/ContactsShell.js +15 -5
- package/dist/apps/shared/components/layout/AppShell.d.ts +29 -4
- package/dist/apps/shared/components/layout/AppShell.js +73 -14
- package/dist/apps/shared/components/layout/KeyEnrollmentGate.js +10 -9
- package/dist/apps/shared/components/layout/MailboxProvisioning.js +3 -1
- package/dist/apps/shared/components/layout/UserMenu.d.ts +19 -3
- package/dist/apps/shared/components/layout/UserMenu.js +52 -5
- package/dist/apps/shared/components/mail/ConversationList.js +4 -11
- package/dist/apps/shared/components/mail/ConversationThreadPane.d.ts +4 -1
- package/dist/apps/shared/components/mail/ConversationThreadPane.js +52 -27
- package/dist/apps/shared/components/mail/LazyReadingPane.d.ts +9 -0
- package/dist/apps/shared/components/mail/LazyReadingPane.js +82 -0
- package/dist/apps/shared/components/mail/MailSelectionBar.d.ts +4 -1
- package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -3
- package/dist/apps/shared/components/mail/MessageDetailPane.d.ts +7 -1
- package/dist/apps/shared/components/mail/MessageDetailPane.js +83 -34
- package/dist/apps/shared/components/mail/NewMailToasts.d.ts +19 -0
- package/dist/apps/shared/components/mail/NewMailToasts.js +55 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +30 -0
- package/dist/apps/shared/components/mail/compose/ComposeContext.js +71 -5
- package/dist/apps/shared/components/mail/compose/ComposeToolbar.js +4 -3
- package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +1 -1
- package/dist/apps/shared/components/mail/compose/ComposeWindow.js +98 -22
- package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.d.ts +19 -0
- package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.js +33 -0
- package/dist/apps/shared/components/mail/compose/RichTextEditor.d.ts +9 -1
- package/dist/apps/shared/components/mail/compose/RichTextEditor.js +20 -2
- package/dist/apps/shared/components/mail/compose/composePerf.d.ts +16 -0
- package/dist/apps/shared/components/mail/compose/composePerf.js +41 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +13 -0
- package/dist/apps/shared/components/mail/compose/quotedBody.js +67 -11
- package/dist/apps/shared/components/mail/layout/MailShell.d.ts +12 -4
- package/dist/apps/shared/components/mail/layout/MailShell.js +76 -96
- package/dist/apps/shared/components/mail/unreadStyle.d.ts +45 -0
- package/dist/apps/shared/components/mail/unreadStyle.js +61 -0
- package/dist/apps/shared/components/settings/layout/SettingsShell.d.ts +1 -1
- package/dist/apps/shared/components/settings/layout/SettingsShell.js +15 -5
- package/dist/apps/shared/components/tasks/layout/TasksShell.d.ts +1 -1
- package/dist/apps/shared/components/tasks/layout/TasksShell.js +15 -5
- package/dist/apps/shared/keyboard/GlobalShortcuts.d.ts +14 -0
- package/dist/apps/shared/keyboard/GlobalShortcuts.js +37 -0
- package/dist/apps/shared/keyboard/ShortcutProvider.d.ts +20 -0
- package/dist/apps/shared/keyboard/ShortcutProvider.js +52 -0
- package/dist/apps/shared/keyboard/ShortcutsDialog.d.ts +14 -0
- package/dist/apps/shared/keyboard/ShortcutsDialog.js +42 -0
- package/dist/apps/shared/keyboard/dispatch.d.ts +16 -0
- package/dist/apps/shared/keyboard/dispatch.js +109 -0
- package/dist/apps/shared/keyboard/format.d.ts +12 -0
- package/dist/apps/shared/keyboard/format.js +74 -0
- package/dist/apps/shared/keyboard/keymap.d.ts +294 -0
- package/dist/apps/shared/keyboard/keymap.js +84 -0
- package/dist/apps/shared/keyboard/match.d.ts +20 -0
- package/dist/apps/shared/keyboard/match.js +31 -0
- package/dist/apps/shared/keyboard/parse.d.ts +31 -0
- package/dist/apps/shared/keyboard/parse.js +107 -0
- package/dist/apps/shared/keyboard/platform.d.ts +15 -0
- package/dist/apps/shared/keyboard/platform.js +22 -0
- package/dist/apps/shared/keyboard/registry.d.ts +39 -0
- package/dist/apps/shared/keyboard/registry.js +33 -0
- package/dist/apps/shared/keyboard/targets.d.ts +14 -0
- package/dist/apps/shared/keyboard/targets.js +67 -0
- package/dist/apps/shared/keyboard/useShortcut.d.ts +19 -0
- package/dist/apps/shared/keyboard/useShortcut.js +35 -0
- package/dist/apps/shared/keyboard/useShortcutProps.d.ts +10 -0
- package/dist/apps/shared/keyboard/useShortcutProps.js +15 -0
- package/dist/apps/shared/mail/folderCounts.d.ts +78 -0
- package/dist/apps/shared/mail/folderCounts.js +212 -0
- package/dist/apps/shared/mail/listSnapshots.d.ts +46 -0
- package/dist/apps/shared/mail/listSnapshots.js +43 -0
- package/dist/apps/shared/mail/messageReadState.d.ts +32 -0
- package/dist/apps/shared/mail/messageReadState.js +63 -0
- package/dist/apps/shared/mail/newMailNotifications.d.ts +62 -0
- package/dist/apps/shared/mail/newMailNotifications.js +138 -0
- package/dist/apps/shared/mail/useMailConnection.d.ts +55 -0
- package/dist/apps/shared/mail/useMailConnection.js +96 -0
- package/dist/apps/shared/mail/useMailLiveUpdates.d.ts +13 -6
- package/dist/apps/shared/mail/useMailLiveUpdates.js +28 -26
- package/dist/apps/shared/mail/useMarkMessageRead.d.ts +12 -0
- package/dist/apps/shared/mail/useMarkMessageRead.js +44 -0
- package/dist/apps/shared/mail/useNewMailNotifications.d.ts +41 -0
- package/dist/apps/shared/mail/useNewMailNotifications.js +110 -0
- package/dist/apps/shared/mail/useUnreadTitle.d.ts +18 -0
- package/dist/apps/shared/mail/useUnreadTitle.js +31 -0
- package/dist/apps/shared/navigation/AppRouter.d.ts +52 -0
- package/dist/apps/shared/navigation/AppRouter.js +242 -0
- package/dist/apps/shared/navigation/appHrefs.d.ts +14 -0
- package/dist/apps/shared/navigation/appHrefs.js +20 -0
- package/dist/apps/shared/navigation/frameContext.d.ts +19 -0
- package/dist/apps/shared/navigation/frameContext.js +24 -0
- package/dist/apps/shared/navigation/idle.d.ts +14 -0
- package/dist/apps/shared/navigation/idle.js +43 -0
- package/dist/apps/shared/navigation/routerContext.d.ts +37 -0
- package/dist/apps/shared/navigation/routerContext.js +56 -0
- package/dist/apps/shared/navigation/routes.d.ts +32 -0
- package/dist/apps/shared/navigation/routes.js +37 -0
- package/dist/apps/shared/search/LocalIndexLifecycle.js +17 -3
- package/dist/apps/shared/styles/app.css +28 -10
- package/dist/apps/www/_routedPage.d.ts +12 -0
- package/dist/apps/www/_routedPage.js +19 -0
- package/dist/apps/www/_routes.d.ts +11 -0
- package/dist/apps/www/_routes.js +29 -0
- package/dist/apps/www/calendar/index.d.ts +2 -2
- package/dist/apps/www/calendar/index.js +39 -8
- package/dist/apps/www/contacts/[uid].d.ts +3 -9
- package/dist/apps/www/contacts/[uid].js +6 -2
- package/dist/apps/www/contacts/index.d.ts +2 -2
- package/dist/apps/www/contacts/index.js +17 -4
- package/dist/apps/www/index.d.ts +2 -2
- package/dist/apps/www/index.js +301 -35
- package/dist/apps/www/messages/[uid].d.ts +3 -7
- package/dist/apps/www/messages/[uid].js +7 -4
- package/dist/apps/www/settings/auto-reply/index.d.ts +2 -2
- package/dist/apps/www/settings/auto-reply/index.js +3 -1
- package/dist/apps/www/settings/encryption/index.d.ts +2 -2
- package/dist/apps/www/settings/encryption/index.js +3 -1
- package/dist/apps/www/settings/filters/[uid].d.ts +2 -2
- package/dist/apps/www/settings/filters/[uid].js +3 -1
- package/dist/apps/www/settings/filters/index.d.ts +2 -2
- package/dist/apps/www/settings/filters/index.js +3 -1
- package/dist/apps/www/settings/filters/new/index.d.ts +2 -2
- package/dist/apps/www/settings/filters/new/index.js +6 -2
- package/dist/apps/www/settings/labels/index.d.ts +2 -2
- package/dist/apps/www/settings/labels/index.js +3 -1
- package/dist/apps/www/settings/privacy/index.d.ts +2 -2
- package/dist/apps/www/settings/privacy/index.js +3 -1
- package/dist/apps/www/settings/read-receipts/index.d.ts +2 -2
- package/dist/apps/www/settings/read-receipts/index.js +3 -1
- package/dist/apps/www/settings/sharing/index.d.ts +2 -2
- package/dist/apps/www/settings/sharing/index.js +3 -1
- package/dist/apps/www/settings/signatures/[uid].d.ts +2 -2
- package/dist/apps/www/settings/signatures/[uid].js +3 -1
- package/dist/apps/www/settings/signatures/index.d.ts +2 -2
- package/dist/apps/www/settings/signatures/index.js +3 -1
- package/dist/apps/www/settings/signatures/new/index.d.ts +2 -2
- package/dist/apps/www/settings/signatures/new/index.js +6 -2
- package/dist/apps/www/tasks/index.d.ts +2 -2
- package/dist/apps/www/tasks/index.js +15 -3
- package/package.json +2 -2
|
@@ -1,472 +1,476 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
-
import React, { createContext, PropsWithChildren, ReactNode,
|
|
6
|
-
import { HiOutlineBars3 } from "react-icons/hi2";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import KeyEnrollmentGate from "../../layout/KeyEnrollmentGate.js";
|
|
14
|
-
import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
|
|
15
|
-
import { useCompose } from "../compose/ComposeContext.js";
|
|
16
|
-
import LocalIndexLifecycle from "../../../search/LocalIndexLifecycle.js";
|
|
17
|
-
import { LiveUpdates, NO_LIVE_UPDATES
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* `
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
)
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
<
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
<
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
>
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
)}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
//
|
|
432
|
-
//
|
|
433
|
-
//
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
//
|
|
444
|
-
//
|
|
445
|
-
|
|
446
|
-
//
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
{
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2026 Jean-Philippe Steinmetz
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
import React, { createContext, PropsWithChildren, ReactNode, useContext, useEffect, useMemo, useState } from "react";
|
|
6
|
+
import { HiOutlineBars3 } from "react-icons/hi2";
|
|
7
|
+
import Drawer from "@rapidmx/react-shared/components/overlays/Drawer.js";
|
|
8
|
+
import { Folder, Mailbox, Message } from "@rapidmx/react-shared/mail/mailApi.js";
|
|
9
|
+
import Alert from "@rapidmx/react-shared/components/feedback/Alert.js";
|
|
10
|
+
import Skeleton, { SkeletonList } from "@rapidmx/react-shared/components/feedback/Skeleton.js";
|
|
11
|
+
import AppShell, { AppShellProps } from "../../layout/AppShell.js";
|
|
12
|
+
import { useLocationSearch, useNavigate } from "../../../navigation/AppRouter.js";
|
|
13
|
+
import KeyEnrollmentGate from "../../layout/KeyEnrollmentGate.js";
|
|
14
|
+
import MailboxProvisioning from "../../layout/MailboxProvisioning.js";
|
|
15
|
+
import { prefetchComposeWindow, useCompose } from "../compose/ComposeContext.js";
|
|
16
|
+
import LocalIndexLifecycle from "../../../search/LocalIndexLifecycle.js";
|
|
17
|
+
import { LiveUpdates, NO_LIVE_UPDATES } from "../../../mail/useMailLiveUpdates.js";
|
|
18
|
+
import { FOLDER_ORDER, MAILBOX_LIST_LIMIT, MailConnectionContext, useMailConnection } from "../../../mail/useMailConnection.js";
|
|
19
|
+
import {
|
|
20
|
+
CountTracker,
|
|
21
|
+
FolderBadge,
|
|
22
|
+
FolderCount,
|
|
23
|
+
badgeFor,
|
|
24
|
+
badgeLabel,
|
|
25
|
+
countOfFolder,
|
|
26
|
+
inboxUnreadTotal,
|
|
27
|
+
} from "../../../mail/folderCounts.js";
|
|
28
|
+
import { useUnreadTitle } from "../../../mail/useUnreadTitle.js";
|
|
29
|
+
import NewMailToasts from "../NewMailToasts.js";
|
|
30
|
+
import { ariaKeyShortcuts, withHint } from "../../../keyboard/format.js";
|
|
31
|
+
import { SHORTCUTS } from "../../../keyboard/keymap.js";
|
|
32
|
+
import { useKeyEnvironment } from "../../../keyboard/ShortcutProvider.js";
|
|
33
|
+
import { useShortcut } from "../../../keyboard/useShortcut.js";
|
|
34
|
+
|
|
35
|
+
export type MailShellProps = Omit<AppShellProps, "active">;
|
|
36
|
+
|
|
37
|
+
/** One mailbox's own mail folders (already filtered to `MAIL_FOLDER_TYPES` and unsorted) - one entry per
|
|
38
|
+
* mailbox in `mailboxes`, fetched in parallel so every accessible mailbox's folder tree can render
|
|
39
|
+
* simultaneously (see `MailShell`'s own doc comment on why this replaced the old single-mailbox `folders`
|
|
40
|
+
* field). `error` is set (and `folders` left empty) for a mailbox whose own `listFolders()` call failed -
|
|
41
|
+
* one mailbox's fetch failure must never blank out every other mailbox's section. */
|
|
42
|
+
export interface MailboxFolders {
|
|
43
|
+
mailbox: Mailbox;
|
|
44
|
+
folders: Folder[];
|
|
45
|
+
error?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The well-known mail folder types an "aggregate" pseudo-folder can merge across every accessible
|
|
49
|
+
* mailbox - a fixed, small set: `outbox` is deliberately excluded (transient per-mailbox send-queue
|
|
50
|
+
* state, not a "merge across mailboxes" concept), and there's no aggregate concept for `calendar`/
|
|
51
|
+
* `contacts`/`tasks`/`notes`/`user` folders (Mail's own sidebar already excludes those - see
|
|
52
|
+
* `MAIL_FOLDER_TYPES`). */
|
|
53
|
+
export const AGGREGATE_FOLDER_TYPES = ["inbox", "sent_items", "drafts", "deleted_items", "junk"] as const;
|
|
54
|
+
export type AggregateFolderType = (typeof AGGREGATE_FOLDER_TYPES)[number];
|
|
55
|
+
|
|
56
|
+
function isAggregateFolderType(value: string | null): value is AggregateFolderType {
|
|
57
|
+
return !!value && (AGGREGATE_FOLDER_TYPES as readonly string[]).includes(value);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface MailShellContextValue {
|
|
61
|
+
/** The mailbox currently selected (`?mailboxUid=`) - `undefined` while an aggregate pseudo-folder is
|
|
62
|
+
* active instead (`aggregateFolderType` set), since there's no single mailbox to speak of then. */
|
|
63
|
+
mailboxUid?: string;
|
|
64
|
+
/** The folder currently selected (`?folderUid=`, or the selected mailbox's Inbox) - `undefined` in
|
|
65
|
+
* aggregate mode, for the same reason. */
|
|
66
|
+
folderUid?: string;
|
|
67
|
+
/** Set only when an aggregate pseudo-folder (`?aggregate=inbox` etc.) is selected instead of a real,
|
|
68
|
+
* single mailbox+folder - mutually exclusive with `mailboxUid`/`folderUid` above. */
|
|
69
|
+
aggregateFolderType?: AggregateFolderType;
|
|
70
|
+
mailboxes: Mailbox[];
|
|
71
|
+
/** Every accessible mailbox's own mail folders - replaces the old single-mailbox `folders: Folder[]`
|
|
72
|
+
* now that every mailbox's tree renders at once (see `MailboxFolders`'s own doc comment). */
|
|
73
|
+
mailboxFolders: MailboxFolders[];
|
|
74
|
+
/**
|
|
75
|
+
* Adds a folder a page has just created (the Move to prompt's "New folder") to the tree this shell
|
|
76
|
+
* already fetched, so it appears in the sidebar and in every folder picker without a reload - this
|
|
77
|
+
* framework has no client-side router, so a reload is a whole page load.
|
|
78
|
+
*
|
|
79
|
+
* A no-op on the default context value, which is only ever read outside a real shell.
|
|
80
|
+
*/
|
|
81
|
+
onFolderCreated: (folder: Folder) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Bumped whenever new mail (or another change to a message) may have arrived - a push event, a reconnect or the safety-net
|
|
84
|
+
* poll - so the list on screen can quietly refetch its first page. See `useMailLiveUpdates()`. Never changes on the default
|
|
85
|
+
* context value, which is only ever read outside a real shell.
|
|
86
|
+
*/
|
|
87
|
+
live: LiveUpdates;
|
|
88
|
+
/**
|
|
89
|
+
* Applies a change to a message (`previous` to `next`; `next` absent when it was deleted) to the folder badges at once, and
|
|
90
|
+
* hands back what to call when the server has answered: `settle()` keeps it, `revert()` takes it back. Every place that
|
|
91
|
+
* reads, moves or deletes a message goes through this (see `setReadState()`), so the badges follow. A no-op on the default
|
|
92
|
+
* context value, which is only ever read outside a real shell.
|
|
93
|
+
*/
|
|
94
|
+
trackMessageChange: (previous: Message, next: Message | null) => CountTracker;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const NO_TRACKER: CountTracker = { settle: () => undefined, revert: () => undefined };
|
|
98
|
+
|
|
99
|
+
const MailShellContext = createContext<MailShellContextValue>({
|
|
100
|
+
mailboxes: [],
|
|
101
|
+
mailboxFolders: [],
|
|
102
|
+
onFolderCreated: () => undefined,
|
|
103
|
+
live: NO_LIVE_UPDATES,
|
|
104
|
+
trackMessageChange: () => NO_TRACKER,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/** Reads the mailbox/folder a page is currently showing, as resolved by the enclosing `MailShell`. */
|
|
108
|
+
export function useMailShell(): MailShellContextValue {
|
|
109
|
+
return useContext(MailShellContext);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const FOLDER_LABELS: Record<string, string> = {
|
|
113
|
+
inbox: "Inbox",
|
|
114
|
+
sent_items: "Sent Items",
|
|
115
|
+
drafts: "Drafts",
|
|
116
|
+
outbox: "Outbox",
|
|
117
|
+
junk: "Junk Email",
|
|
118
|
+
archive: "Archive",
|
|
119
|
+
deleted_items: "Deleted Items",
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
function folderSortKey(folder: Folder): number {
|
|
123
|
+
const idx = FOLDER_ORDER.indexOf(folder.type);
|
|
124
|
+
return idx === -1 ? FOLDER_ORDER.length : idx;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function sortedFoldersOf(folders: Folder[]): Folder[] {
|
|
128
|
+
return [...folders].sort((a, b) => folderSortKey(a) - folderSortKey(b) || a.name.localeCompare(b.name));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The badge an "All Mailboxes" entry shows: the folders of that type, summed across every mailbox, under the same rules as a single folder's. */
|
|
132
|
+
function aggregateBadge(mailboxFolders: MailboxFolders[], type: AggregateFolderType, counts: Record<string, FolderCount>): FolderBadge | undefined {
|
|
133
|
+
const sum = mailboxFolders.reduce(
|
|
134
|
+
(total, mf) => {
|
|
135
|
+
const folder = mf.folders.find((f) => f.type === type);
|
|
136
|
+
const count = folder ? countOfFolder(folder, counts) : { unread: 0, total: 0 };
|
|
137
|
+
return { unread: total.unread + count.unread, total: total.total + count.total };
|
|
138
|
+
},
|
|
139
|
+
{ unread: 0, total: 0 },
|
|
140
|
+
);
|
|
141
|
+
return badgeFor(type, sum);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** A folder's badge: an accent pill with the unread count, or - for the folders that show how many they hold - plain muted text. */
|
|
145
|
+
function FolderBadgeChip({ badge }: { badge: FolderBadge }) {
|
|
146
|
+
return (
|
|
147
|
+
<span
|
|
148
|
+
className={[
|
|
149
|
+
"text-xs rounded-pill py-0.5 px-1.5",
|
|
150
|
+
badge.kind === "unread" ? "font-bold bg-primary/15 text-primary-dark" : "font-medium text-text-muted",
|
|
151
|
+
].join(" ")}
|
|
152
|
+
>
|
|
153
|
+
<span aria-hidden="true">{badge.value}</span>
|
|
154
|
+
<span className="sr-only"> {badgeLabel(badge)}</span>
|
|
155
|
+
</span>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
type Status = "checking" | "error" | "ready";
|
|
160
|
+
|
|
161
|
+
export { MAILBOX_LIST_LIMIT };
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* A separate component (not inlined into `MailShell`'s own render) so `useCompose()` resolves against
|
|
165
|
+
* `ComposeProvider` correctly: that provider is rendered *inside* the `AppShell` that `MailShell` itself
|
|
166
|
+
* returns, i.e. a descendant of `MailShell`, not an ancestor — a hook call made directly in `MailShell`'s
|
|
167
|
+
* own function body would see only whatever context exists *above* `MailShell`, never a provider one of
|
|
168
|
+
* its own descendants creates. This button, rendered as part of `AppShell`'s `children`, sits correctly
|
|
169
|
+
* inside that subtree.
|
|
170
|
+
*
|
|
171
|
+
* Opens with the caller's own mailbox (the shell has already listed them), so the window can start on its
|
|
172
|
+
* signature, draft and encryption lookups straight away instead of first asking which mailbox that is; the
|
|
173
|
+
* compose window's own From field is where the sender is chosen. Fetches the window's code as the pointer or
|
|
174
|
+
* keyboard reaches the button, so the click finds it already here.
|
|
175
|
+
*/
|
|
176
|
+
function ComposeButton({ mailboxUid }: { mailboxUid?: string }) {
|
|
177
|
+
const { openCompose } = useCompose();
|
|
178
|
+
const env = useKeyEnvironment();
|
|
179
|
+
return (
|
|
180
|
+
<button
|
|
181
|
+
type="button"
|
|
182
|
+
title={withHint("Compose", SHORTCUTS.mail.create, env)}
|
|
183
|
+
aria-keyshortcuts={ariaKeyShortcuts(SHORTCUTS.mail.create, env)}
|
|
184
|
+
onClick={() => openCompose({ mailboxUid })}
|
|
185
|
+
onPointerEnter={prefetchComposeWindow}
|
|
186
|
+
onFocus={prefetchComposeWindow}
|
|
187
|
+
className="block text-center w-full py-2.5 px-4 rounded-sm font-semibold text-sm bg-primary text-white hover:bg-primary-dark"
|
|
188
|
+
>
|
|
189
|
+
Compose
|
|
190
|
+
</button>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Mail's keyboard shortcuts that don't belong to a list or a message: "New message". A component of its own for the reason `ComposeButton`
|
|
196
|
+
* is - `useCompose()` only resolves below `ComposeProvider`, i.e. inside the `AppShell` this shell renders - and mounted once, whatever number
|
|
197
|
+
* of Compose buttons (the sidebar, the folders drawer) are on screen. Opens the same window, for the same mailbox, as the button.
|
|
198
|
+
*/
|
|
199
|
+
function MailShortcuts({ mailboxUid }: { mailboxUid?: string }) {
|
|
200
|
+
const { openCompose } = useCompose();
|
|
201
|
+
useShortcut(SHORTCUTS.mail.create, () => openCompose({ mailboxUid }));
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Mail's own contextual sidebar (every accessible mailbox's own folder tree, plus a merged "All Mailboxes"
|
|
207
|
+
* aggregate section) + content area, rendered inside the shared `AppShell` chrome (icon rail, header,
|
|
208
|
+
* impersonation banner — see that component). There is no client-side router in this framework (see
|
|
209
|
+
* `ReactRoute`'s file-convention resolver) — the selected mailbox/folder (or aggregate pseudo-folder) live
|
|
210
|
+
* in the URL's `?mailboxUid=`/`?folderUid=`/`?aggregate=` query params, read once on mount (never during
|
|
211
|
+
* the initial render itself, matching every other query-param reader in this codebase — e.g.
|
|
212
|
+
* `apps/admin/quarantine`'s `readMailboxUid()` — so the server-rendered and just-hydrated client markup
|
|
213
|
+
* match).
|
|
214
|
+
*
|
|
215
|
+
* Every accessible mailbox's folder tree renders at once - there is no "switch mailbox" affordance
|
|
216
|
+
* anymore (the mailbox `<select>` this shell used to have is gone) - so a single-mailbox user sees zero
|
|
217
|
+
* behavior change from before this, and a multi-mailbox user sees every mailbox's folders (and the new
|
|
218
|
+
* aggregate section) simultaneously, matching the shared-mailbox feature's own "display as a separate set
|
|
219
|
+
* of folders" requirement.
|
|
220
|
+
*/
|
|
221
|
+
export default function MailShell({
|
|
222
|
+
userUid,
|
|
223
|
+
authServerUrl,
|
|
224
|
+
impersonating,
|
|
225
|
+
impersonationBaseUrl,
|
|
226
|
+
trusted,
|
|
227
|
+
trustedRoles,
|
|
228
|
+
pluginNav,
|
|
229
|
+
children,
|
|
230
|
+
}: PropsWithChildren<MailShellProps>) {
|
|
231
|
+
// The mailboxes, their folders and the live connection come from the persistent app frame when there is one (`AppChrome` owns them, so
|
|
232
|
+
// they survive Mail -> Calendar -> Mail and the push socket, pop-ups, counters and tab title work in every app). A page rendered
|
|
233
|
+
// outside the frame - a test, a plugin page - has no frame to ask, so this shell runs the same hook for itself, and renders the pop-ups.
|
|
234
|
+
const navigate = useNavigate();
|
|
235
|
+
const hosted = useContext(MailConnectionContext);
|
|
236
|
+
const own = useMailConnection({ userUid, enabled: !hosted, open: navigate });
|
|
237
|
+
const { status, error, mailboxes, mailboxFolders, foldersLoading, onFolderCreated, live, folderCounts, notifications } = hosted ?? own;
|
|
238
|
+
const [requestedMailboxUid, setRequestedMailboxUid] = useState<string | null>(null);
|
|
239
|
+
const [requestedFolderUid, setRequestedFolderUid] = useState<string | null>(null);
|
|
240
|
+
const [requestedAggregateType, setRequestedAggregateType] = useState<string | null>(null);
|
|
241
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
242
|
+
|
|
243
|
+
// The selection lives in the URL, and the router (`AppRouter`) changes the URL without a page load when a folder link is
|
|
244
|
+
// clicked - so it is read from the router's location, which updates, rather than once from `window.location`. Still read
|
|
245
|
+
// in an effect, never during the first render, so the server render and the hydrating render agree.
|
|
246
|
+
const search = useLocationSearch();
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
const params = new URLSearchParams(search);
|
|
249
|
+
setRequestedMailboxUid(params.get("mailboxUid"));
|
|
250
|
+
setRequestedFolderUid(params.get("folderUid"));
|
|
251
|
+
setRequestedAggregateType(params.get("aggregate"));
|
|
252
|
+
}, [search]);
|
|
253
|
+
// Choosing a folder (or mailbox) changes the URL without a page load now, so the drawer that held the choice - which used to go
|
|
254
|
+
// with the page - is closed here.
|
|
255
|
+
useEffect(() => {
|
|
256
|
+
setDrawerOpen(false);
|
|
257
|
+
}, [search]);
|
|
258
|
+
|
|
259
|
+
const aggregateFolderType: AggregateFolderType | undefined = isAggregateFolderType(requestedAggregateType)
|
|
260
|
+
? requestedAggregateType
|
|
261
|
+
: undefined;
|
|
262
|
+
|
|
263
|
+
const mailboxUid: string | undefined = aggregateFolderType
|
|
264
|
+
? undefined
|
|
265
|
+
: (requestedMailboxUid && mailboxes.some((mb) => mb.uid === requestedMailboxUid) ? requestedMailboxUid : undefined) ??
|
|
266
|
+
mailboxes[0]?.uid;
|
|
267
|
+
|
|
268
|
+
const selectedMailboxFolders = mailboxFolders.find((mf) => mf.mailbox.uid === mailboxUid)?.folders ?? [];
|
|
269
|
+
const folderUid: string | undefined = aggregateFolderType
|
|
270
|
+
? undefined
|
|
271
|
+
: (requestedFolderUid && selectedMailboxFolders.some((f) => f.uid === requestedFolderUid) ? requestedFolderUid : undefined) ??
|
|
272
|
+
selectedMailboxFolders.find((f) => f.type === "inbox")?.uid;
|
|
273
|
+
|
|
274
|
+
// The mailbox `KeyEnrollmentGate`/`LocalIndexLifecycle`/`ComposeButton` treat as "the" mailbox when
|
|
275
|
+
// there's no single selected one to use (aggregate mode) - the caller's own owned mailbox if they
|
|
276
|
+
// have one, else whichever accessible mailbox happens to be first. See MailShell's own doc comment on
|
|
277
|
+
// this being an accepted limitation: an aggregate-view message from a *different*, not-yet-visited
|
|
278
|
+
// mailbox may still need that mailbox's own folder view opened directly to unlock/decrypt it.
|
|
279
|
+
const defaultMailboxUid = mailboxes.find((mb) => mb.ownerUserUid === userUid)?.uid ?? mailboxes[0]?.uid;
|
|
280
|
+
const activeMailboxUid = mailboxUid ?? defaultMailboxUid;
|
|
281
|
+
|
|
282
|
+
const counts = folderCounts.counts;
|
|
283
|
+
const trackMessageChange = folderCounts.track;
|
|
284
|
+
// `(3) Acme: Mail` in the tab strip while there is unread mail in an Inbox - kept by the frame when there is one.
|
|
285
|
+
useUnreadTitle(inboxUnreadTotal(mailboxFolders, counts), { enabled: !hosted });
|
|
286
|
+
|
|
287
|
+
const contextValue = useMemo<MailShellContextValue>(
|
|
288
|
+
() => ({ mailboxUid, folderUid, aggregateFolderType, mailboxes, mailboxFolders, onFolderCreated, live, trackMessageChange }),
|
|
289
|
+
[mailboxUid, folderUid, aggregateFolderType, mailboxes, mailboxFolders, onFolderCreated, live, trackMessageChange],
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
// A full-screen takeover, not nested inside the rest of the app's chrome — there's nothing else for a
|
|
293
|
+
// mailbox-less caller to do here yet, so the icon rail/header/folder tree don't render at all. Checks
|
|
294
|
+
// `mailboxes.length` directly (not `!mailboxUid`) since `mailboxUid` is legitimately undefined in
|
|
295
|
+
// aggregate mode even with mailboxes present.
|
|
296
|
+
if (userUid && status === "ready" && mailboxes.length === 0) {
|
|
297
|
+
return <MailboxProvisioning />;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
let inner: ReactNode = null;
|
|
301
|
+
if (userUid && status === "checking") {
|
|
302
|
+
// Renders immediately (no network round trip needed) so switching into Mail never shows a blank
|
|
303
|
+
// pane while `listMailboxes()` is in flight — the outline below mirrors the real sidebar's shape.
|
|
304
|
+
inner = (
|
|
305
|
+
<aside className="w-64 shrink-0 bg-surface border-r border-border flex flex-col p-3 gap-4">
|
|
306
|
+
<Skeleton height="h-9" className="rounded-sm" />
|
|
307
|
+
<SkeletonList count={6} />
|
|
308
|
+
</aside>
|
|
309
|
+
);
|
|
310
|
+
} else if (userUid && status === "error") {
|
|
311
|
+
inner = (
|
|
312
|
+
<div className="flex-1 flex items-center justify-center p-8">
|
|
313
|
+
<div className="w-full max-w-md">
|
|
314
|
+
<Alert>{error}</Alert>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
);
|
|
318
|
+
} else if (userUid && status === "ready") {
|
|
319
|
+
// A function, not a plain JSX constant — it's rendered twice (desktop `<aside>` + mobile
|
|
320
|
+
// `Drawer`), possibly *simultaneously* mounted (the aside is only CSS-hidden below `md`, not
|
|
321
|
+
// unmounted).
|
|
322
|
+
const sidebarContent = () => (
|
|
323
|
+
<>
|
|
324
|
+
<div className="p-3">
|
|
325
|
+
<ComposeButton mailboxUid={defaultMailboxUid} />
|
|
326
|
+
</div>
|
|
327
|
+
{foldersLoading ? (
|
|
328
|
+
<div className="flex-1 overflow-y-auto px-3 pb-3">
|
|
329
|
+
<SkeletonList count={6} className="pt-1" />
|
|
330
|
+
</div>
|
|
331
|
+
) : (
|
|
332
|
+
<nav className="flex-1 overflow-y-auto px-3 pb-3 flex flex-col gap-3">
|
|
333
|
+
{mailboxes.length > 1 && (
|
|
334
|
+
<div>
|
|
335
|
+
<div className="text-xs font-bold uppercase tracking-wide text-text-muted mb-1 px-2.5">
|
|
336
|
+
All Mailboxes
|
|
337
|
+
</div>
|
|
338
|
+
<div className="flex flex-col gap-0.5">
|
|
339
|
+
{AGGREGATE_FOLDER_TYPES.map((type) => {
|
|
340
|
+
const badge = aggregateBadge(mailboxFolders, type, counts);
|
|
341
|
+
return (
|
|
342
|
+
<a
|
|
343
|
+
key={type}
|
|
344
|
+
href={`/?aggregate=${encodeURIComponent(type)}`}
|
|
345
|
+
className={[
|
|
346
|
+
"flex items-center justify-between text-sm rounded-sm py-1.5 px-2.5",
|
|
347
|
+
aggregateFolderType === type
|
|
348
|
+
? "bg-primary/10 text-primary-dark font-semibold"
|
|
349
|
+
: "text-text hover:bg-surface-alt",
|
|
350
|
+
].join(" ")}
|
|
351
|
+
>
|
|
352
|
+
<span className={badge?.kind === "unread" ? "font-semibold" : undefined}>{FOLDER_LABELS[type]}</span>
|
|
353
|
+
{badge && <FolderBadgeChip badge={badge} />}
|
|
354
|
+
</a>
|
|
355
|
+
);
|
|
356
|
+
})}
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
)}
|
|
360
|
+
{mailboxFolders.map(({ mailbox, folders, error: mailboxError }) => (
|
|
361
|
+
<div key={mailbox.uid}>
|
|
362
|
+
<div className="text-xs font-bold uppercase tracking-wide text-text-muted mb-1 px-2.5 truncate">
|
|
363
|
+
{mailbox.displayName}
|
|
364
|
+
{mailbox.ownerUserUid ? "" : " (shared)"}
|
|
365
|
+
</div>
|
|
366
|
+
{mailboxError && (
|
|
367
|
+
<div className="px-2.5 pb-1">
|
|
368
|
+
<Alert>{mailboxError}</Alert>
|
|
369
|
+
</div>
|
|
370
|
+
)}
|
|
371
|
+
<div className="flex flex-col gap-0.5">
|
|
372
|
+
{sortedFoldersOf(folders).map((folder) => {
|
|
373
|
+
const badge = badgeFor(folder.type, countOfFolder(folder, counts));
|
|
374
|
+
return (
|
|
375
|
+
<a
|
|
376
|
+
key={folder.uid}
|
|
377
|
+
href={`/?mailboxUid=${encodeURIComponent(mailbox.uid)}&folderUid=${encodeURIComponent(folder.uid)}`}
|
|
378
|
+
className={[
|
|
379
|
+
"flex items-center justify-between text-sm rounded-sm py-1.5 px-2.5",
|
|
380
|
+
folder.uid === folderUid
|
|
381
|
+
? "bg-primary/10 text-primary-dark font-semibold"
|
|
382
|
+
: "text-text hover:bg-surface-alt",
|
|
383
|
+
].join(" ")}
|
|
384
|
+
>
|
|
385
|
+
<span className={badge?.kind === "unread" ? "font-semibold" : undefined}>
|
|
386
|
+
{FOLDER_LABELS[folder.type] ?? folder.name}
|
|
387
|
+
</span>
|
|
388
|
+
{badge && <FolderBadgeChip badge={badge} />}
|
|
389
|
+
</a>
|
|
390
|
+
);
|
|
391
|
+
})}
|
|
392
|
+
</div>
|
|
393
|
+
</div>
|
|
394
|
+
))}
|
|
395
|
+
</nav>
|
|
396
|
+
)}
|
|
397
|
+
</>
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
inner = (
|
|
401
|
+
<>
|
|
402
|
+
<MailShortcuts mailboxUid={defaultMailboxUid} />
|
|
403
|
+
<aside className="hidden md:flex w-64 shrink-0 bg-surface border-r border-border flex-col">{sidebarContent()}</aside>
|
|
404
|
+
<Drawer open={drawerOpen} onClose={() => setDrawerOpen(false)} title="Folders">
|
|
405
|
+
<div className="flex flex-col">{sidebarContent()}</div>
|
|
406
|
+
</Drawer>
|
|
407
|
+
<main className="flex-1 min-w-0 overflow-y-auto">
|
|
408
|
+
<button
|
|
409
|
+
type="button"
|
|
410
|
+
className="md:hidden m-3 w-9 h-9 flex items-center justify-center rounded-sm text-text-muted hover:bg-surface-alt hover:text-text"
|
|
411
|
+
aria-label="Open folders"
|
|
412
|
+
onClick={() => setDrawerOpen(true)}
|
|
413
|
+
>
|
|
414
|
+
<HiOutlineBars3 size={20} aria-hidden="true" />
|
|
415
|
+
</button>
|
|
416
|
+
<MailShellContext.Provider value={contextValue}>{children}</MailShellContext.Provider>
|
|
417
|
+
</main>
|
|
418
|
+
{!hosted && (
|
|
419
|
+
<NewMailToasts
|
|
420
|
+
toasts={notifications.toasts}
|
|
421
|
+
onDismiss={notifications.dismiss}
|
|
422
|
+
offerDesktop={notifications.offerDesktop}
|
|
423
|
+
onEnableDesktop={() => void notifications.enableDesktop()}
|
|
424
|
+
onDeclineDesktop={notifications.declineDesktop}
|
|
425
|
+
/>
|
|
426
|
+
)}
|
|
427
|
+
</>
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Wraps AppShell unconditionally, at a stable tree position regardless of whether mailboxUid has
|
|
432
|
+
// resolved yet - KeyEnrollmentGate itself passes `children` through untouched until a real
|
|
433
|
+
// mailboxUid is supplied (see its own doc comment). Wrapping only once ready (a conditional tree
|
|
434
|
+
// position) would make AppShell itself remount the moment mailboxUid resolves, tearing down
|
|
435
|
+
// whatever state/effects it had already started (confirmed by direct reproduction: the
|
|
436
|
+
// impersonation banner's own internal state was lost exactly at that transition).
|
|
437
|
+
const activeMailbox = mailboxes.find((mb) => mb.uid === activeMailboxUid);
|
|
438
|
+
return (
|
|
439
|
+
<KeyEnrollmentGate
|
|
440
|
+
mailboxUid={activeMailboxUid}
|
|
441
|
+
mailboxAddress={activeMailbox?.primarySmtpAddress}
|
|
442
|
+
mailboxKeys={activeMailbox?.keys}
|
|
443
|
+
// Unlocking is only actually required to sign/encrypt a compose, read an already-encrypted
|
|
444
|
+
// message, or change encryption settings - not merely to open Mail. Those specific call sites
|
|
445
|
+
// (ComposeWindow, MessageDetailPane) request an unlock on demand via useUnlockPrompt() instead.
|
|
446
|
+
// First-time provisioning (a mailbox with no vault at all yet) still always blocks - see this
|
|
447
|
+
// prop's own doc comment on KeyEnrollmentGateProps.
|
|
448
|
+
blocking={false}
|
|
449
|
+
// A shared/delegated mailbox the caller doesn't own is never provisioned from here - its keys
|
|
450
|
+
// belong to its owner (or its admins), not to whoever happens to open it first - and neither is
|
|
451
|
+
// the impersonated user's own mailbox: an administrator must never choose its password/recovery codes.
|
|
452
|
+
canProvision={!impersonating && activeMailbox?.ownerUserUid === userUid}
|
|
453
|
+
>
|
|
454
|
+
<LocalIndexLifecycle
|
|
455
|
+
mailboxUid={activeMailboxUid}
|
|
456
|
+
mailboxKeys={activeMailbox?.keys}
|
|
457
|
+
folders={mailboxFolders.find((mf) => mf.mailbox.uid === activeMailboxUid)?.folders ?? []}
|
|
458
|
+
// A full page may be truncated - pruning against it would delete indexes of accessible mailboxes
|
|
459
|
+
// beyond the limit, so it's only trusted as the complete list when it came back short.
|
|
460
|
+
accessibleMailboxUids={status === "ready" && mailboxes.length < MAILBOX_LIST_LIMIT ? mailboxes.map((mb) => mb.uid) : undefined}
|
|
461
|
+
/>
|
|
462
|
+
<AppShell
|
|
463
|
+
active="mail"
|
|
464
|
+
userUid={userUid}
|
|
465
|
+
authServerUrl={authServerUrl}
|
|
466
|
+
impersonating={impersonating}
|
|
467
|
+
impersonationBaseUrl={impersonationBaseUrl}
|
|
468
|
+
trusted={trusted}
|
|
469
|
+
trustedRoles={trustedRoles}
|
|
470
|
+
pluginNav={pluginNav}
|
|
471
|
+
>
|
|
472
|
+
{inner}
|
|
473
|
+
</AppShell>
|
|
474
|
+
</KeyEnrollmentGate>
|
|
475
|
+
);
|
|
476
|
+
}
|