@rapidmx/web-client 0.28.0 → 0.29.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.
Files changed (119) hide show
  1. package/README.md +3 -0
  2. package/apps/shared/components/admin/diagnostics/DiagnosticsManager.tsx +22 -10
  3. package/apps/shared/components/admin/diagnostics/InformationPanel.tsx +60 -0
  4. package/apps/shared/components/admin/diagnostics/SettingsTable.tsx +108 -0
  5. package/apps/shared/components/admin/diagnostics/diagnosticsApi.ts +25 -1
  6. package/apps/shared/components/calendar/CalendarSearchBox.tsx +83 -0
  7. package/apps/shared/components/calendar/EventMatchNav.tsx +72 -0
  8. package/apps/shared/components/calendar/EventModal.tsx +33 -12
  9. package/apps/shared/components/calendar/ListView.tsx +207 -0
  10. package/apps/shared/components/calendar/MonthView.tsx +14 -2
  11. package/apps/shared/components/calendar/SlideIn.tsx +47 -0
  12. package/apps/shared/components/calendar/SplitDayView.tsx +5 -0
  13. package/apps/shared/components/calendar/TimeGridView.tsx +23 -12
  14. package/apps/shared/components/calendar/activeOccurrence.ts +28 -0
  15. package/apps/shared/components/calendar/allDay.ts +16 -1
  16. package/apps/shared/components/calendar/calendarView.ts +41 -0
  17. package/apps/shared/components/layout/AppShell.tsx +13 -6
  18. package/apps/shared/components/mail/ConversationList.tsx +29 -3
  19. package/apps/shared/components/mail/ConversationThreadPane.tsx +15 -0
  20. package/apps/shared/components/mail/MailSelectionBar.tsx +117 -55
  21. package/apps/shared/components/mail/MessageDetailPane.tsx +3 -0
  22. package/apps/shared/components/mail/compose/ComposeContext.tsx +193 -35
  23. package/apps/shared/components/mail/compose/ComposeWindow.tsx +62 -11
  24. package/apps/shared/components/mail/compose/ComposeWindowPlaceholder.tsx +21 -10
  25. package/apps/shared/components/mail/compose/RichTextEditor.tsx +2 -1
  26. package/apps/shared/components/mail/compose/quotedBody.ts +45 -2
  27. package/apps/shared/components/mail/labelMenu.tsx +4 -0
  28. package/apps/shared/components/mail/layout/MailShell.tsx +9 -2
  29. package/apps/shared/components/mail/reading/MessageBody.tsx +1 -1
  30. package/apps/shared/components/mail/reading/bodyContent.ts +15 -13
  31. package/apps/shared/components/mail/reading/bodyHtml.ts +12 -7
  32. package/apps/shared/gestures/useEnterSlide.ts +1 -1
  33. package/apps/shared/keyboard/keymap.ts +2 -0
  34. package/apps/shared/mail/rangeSelection.ts +45 -0
  35. package/apps/shared/mail/rowExit.ts +39 -0
  36. package/apps/www/calendar/index.tsx +251 -53
  37. package/apps/www/index.tsx +522 -343
  38. package/dist/apps/shared/components/admin/diagnostics/DiagnosticsManager.d.ts +3 -3
  39. package/dist/apps/shared/components/admin/diagnostics/DiagnosticsManager.js +15 -9
  40. package/dist/apps/shared/components/admin/diagnostics/InformationPanel.d.ts +15 -0
  41. package/dist/apps/shared/components/admin/diagnostics/InformationPanel.js +16 -0
  42. package/dist/apps/shared/components/admin/diagnostics/SettingsTable.d.ts +20 -0
  43. package/dist/apps/shared/components/admin/diagnostics/SettingsTable.js +31 -0
  44. package/dist/apps/shared/components/admin/diagnostics/diagnosticsApi.d.ts +20 -1
  45. package/dist/apps/shared/components/admin/diagnostics/diagnosticsApi.js +7 -0
  46. package/dist/apps/shared/components/calendar/CalendarSearchBox.d.ts +22 -0
  47. package/dist/apps/shared/components/calendar/CalendarSearchBox.js +24 -0
  48. package/dist/apps/shared/components/calendar/EventMatchNav.d.ts +17 -0
  49. package/dist/apps/shared/components/calendar/EventMatchNav.js +37 -0
  50. package/dist/apps/shared/components/calendar/EventModal.d.ts +17 -1
  51. package/dist/apps/shared/components/calendar/EventModal.js +13 -11
  52. package/dist/apps/shared/components/calendar/ListView.d.ts +30 -0
  53. package/dist/apps/shared/components/calendar/ListView.js +111 -0
  54. package/dist/apps/shared/components/calendar/MonthView.js +12 -3
  55. package/dist/apps/shared/components/calendar/SlideIn.d.ts +16 -0
  56. package/dist/apps/shared/components/calendar/SlideIn.js +32 -0
  57. package/dist/apps/shared/components/calendar/SplitDayView.js +5 -1
  58. package/dist/apps/shared/components/calendar/TimeGridView.js +11 -3
  59. package/dist/apps/shared/components/calendar/activeOccurrence.d.ts +15 -0
  60. package/dist/apps/shared/components/calendar/activeOccurrence.js +21 -0
  61. package/dist/apps/shared/components/calendar/allDay.d.ts +4 -0
  62. package/dist/apps/shared/components/calendar/allDay.js +14 -1
  63. package/dist/apps/shared/components/calendar/calendarView.d.ts +16 -0
  64. package/dist/apps/shared/components/calendar/calendarView.js +36 -0
  65. package/dist/apps/shared/components/layout/AppShell.js +8 -4
  66. package/dist/apps/shared/components/mail/ConversationList.d.ts +9 -1
  67. package/dist/apps/shared/components/mail/ConversationList.js +10 -2
  68. package/dist/apps/shared/components/mail/ConversationThreadPane.js +9 -1
  69. package/dist/apps/shared/components/mail/MailSelectionBar.js +11 -4
  70. package/dist/apps/shared/components/mail/MessageDetailPane.js +3 -0
  71. package/dist/apps/shared/components/mail/compose/ComposeContext.d.ts +31 -0
  72. package/dist/apps/shared/components/mail/compose/ComposeContext.js +123 -11
  73. package/dist/apps/shared/components/mail/compose/ComposeWindow.d.ts +6 -1
  74. package/dist/apps/shared/components/mail/compose/ComposeWindow.js +37 -11
  75. package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.d.ts +5 -1
  76. package/dist/apps/shared/components/mail/compose/ComposeWindowPlaceholder.js +10 -6
  77. package/dist/apps/shared/components/mail/compose/RichTextEditor.js +2 -1
  78. package/dist/apps/shared/components/mail/compose/quotedBody.d.ts +3 -0
  79. package/dist/apps/shared/components/mail/compose/quotedBody.js +43 -1
  80. package/dist/apps/shared/components/mail/labelMenu.d.ts +3 -1
  81. package/dist/apps/shared/components/mail/labelMenu.js +2 -2
  82. package/dist/apps/shared/components/mail/layout/MailShell.js +7 -1
  83. package/dist/apps/shared/components/mail/reading/MessageBody.js +1 -1
  84. package/dist/apps/shared/components/mail/reading/bodyContent.d.ts +5 -1
  85. package/dist/apps/shared/components/mail/reading/bodyContent.js +11 -11
  86. package/dist/apps/shared/components/mail/reading/bodyHtml.d.ts +3 -2
  87. package/dist/apps/shared/components/mail/reading/bodyHtml.js +8 -4
  88. package/dist/apps/shared/gestures/useEnterSlide.d.ts +2 -0
  89. package/dist/apps/shared/gestures/useEnterSlide.js +1 -1
  90. package/dist/apps/shared/keyboard/keymap.d.ts +12 -0
  91. package/dist/apps/shared/keyboard/keymap.js +2 -0
  92. package/dist/apps/shared/mail/rangeSelection.d.ts +20 -0
  93. package/dist/apps/shared/mail/rangeSelection.js +34 -0
  94. package/dist/apps/shared/mail/rowExit.d.ts +12 -0
  95. package/dist/apps/shared/mail/rowExit.js +33 -0
  96. package/dist/apps/www/calendar/index.js +177 -18
  97. package/dist/apps/www/index.js +220 -65
  98. package/dist/lib/calendar/eventSearch.d.ts +42 -0
  99. package/dist/lib/calendar/eventSearch.js +152 -0
  100. package/dist/lib/components/navigation/BottomTabBar.d.ts +15 -3
  101. package/dist/lib/components/navigation/BottomTabBar.js +52 -15
  102. package/dist/lib/components/navigation/NavBadge.d.ts +13 -0
  103. package/dist/lib/components/navigation/NavBadge.js +18 -0
  104. package/dist/lib/mail/compose/quotedImages.d.ts +21 -0
  105. package/dist/lib/mail/compose/quotedImages.js +41 -0
  106. package/dist/lib/mail/inlineImages.d.ts +38 -0
  107. package/dist/lib/mail/inlineImages.js +90 -0
  108. package/dist/lib/mail/mailApi.d.ts +8 -1
  109. package/dist/lib/mail/mailApi.js +57 -5
  110. package/lib/calendar/eventSearch.ts +172 -0
  111. package/lib/components/navigation/BottomTabBar.tsx +107 -22
  112. package/lib/components/navigation/NavBadge.tsx +33 -0
  113. package/lib/mail/compose/quotedImages.ts +49 -0
  114. package/lib/mail/inlineImages.ts +104 -0
  115. package/lib/mail/mailApi.ts +64 -5
  116. package/package.json +1 -1
  117. package/apps/shared/components/admin/diagnostics/VersionsPanel.tsx +0 -36
  118. package/dist/apps/shared/components/admin/diagnostics/VersionsPanel.d.ts +0 -10
  119. package/dist/apps/shared/components/admin/diagnostics/VersionsPanel.js +0 -11
@@ -63,6 +63,8 @@ import MailShell, {
63
63
  import MailAddress from "../shared/components/mail/MailAddress.js";
64
64
  import OutboxRowStatus from "../shared/components/mail/OutboxRowStatus.js";
65
65
  import { mergeFirstPage } from "../shared/mail/mergeFirstPage.js";
66
+ import { ClickModifiers, isToggleClick, rangeBetween, resolveAnchor } from "../shared/mail/rangeSelection.js";
67
+ import { ROW_EXIT_MS, canAnimateRowExit, collapseRow } from "../shared/mail/rowExit.js";
66
68
  import { isOwnMailbox, orderMailboxes, primaryMailboxUid } from "../shared/mail/primaryMailbox.js";
67
69
  import { listSnapshotKey, readListSnapshot, saveListScroll, writeListSnapshot } from "../shared/mail/listSnapshots.js";
68
70
  import { setReadStateMany } from "../shared/mail/messageReadState.js";
@@ -770,6 +772,18 @@ function InboxContent({ userUid }: { userUid?: string }) {
770
772
  // Where the message the keyboard just removed from the list (deleted, archived, moved) was: the next Down/Up continues from that spot, so
771
773
  // clearing an inbox from the keyboard walks down it instead of jumping back to the top. Cleared by any selection.
772
774
  const removedAnchorRef = useRef<number | null>(null);
775
+ // The row a Shift+click range starts from: the row last clicked or opened (a `message.uid`, or a `conversationRowKey()` in the conversation list).
776
+ // A Shift+click selects from here to the clicked row but leaves it where it is, so the next Shift+click re-spans from the same row, as in Explorer and
777
+ // Outlook; a plain click or a Ctrl+click moves it to the row clicked. Forgotten when the listing is replaced. See `resolveAnchor()`.
778
+ const selectionAnchorRef = useRef<string | null>(null);
779
+ // Rows on their way out of the list (moved, deleted, archived): `message.uid`s, or `conversationRowKey()`s in the conversation list. They stay in the
780
+ // data while they collapse (`collapseRow()`, `ROW_EXIT_MS`), so the rows below slide up into the gap, and are dropped by `animateRowsOut()` after.
781
+ const [exitingKeys, setExitingKeys] = useState<Set<string>>(new Set());
782
+ const exitTimersRef = useRef<Set<ReturnType<typeof setTimeout>>>(new Set());
783
+ useEffect(() => {
784
+ const timers = exitTimersRef.current;
785
+ return () => timers.forEach(clearTimeout);
786
+ }, []);
773
787
  // State (via a callback ref), not a plain ref: the sentinel mounts and unmounts as the list loads,
774
788
  // filters, and empties, and the observer effect below must re-attach to whichever node is current.
775
789
  const [sentinel, setSentinel] = useState<HTMLDivElement | null>(null);
@@ -1040,6 +1054,7 @@ function InboxContent({ userUid }: { userUid?: string }) {
1040
1054
  setSelectedUids(new Set());
1041
1055
  setSelectedConversationIds(new Set());
1042
1056
  setConversationMessagesById({});
1057
+ selectionAnchorRef.current = null;
1043
1058
  listedOffsetRef.current = 0;
1044
1059
  compositeCursorRef.current = undefined;
1045
1060
  setHasMore(false);
@@ -1454,22 +1469,16 @@ function InboxContent({ userUid }: { userUid?: string }) {
1454
1469
  // a listing still loading and a "load more" in flight, and for events about folders the list isn't showing - a
1455
1470
  // conversation list, which can span folders, refreshes for any. Any failure is silent: the next tick tries again.
1456
1471
  const liveRunRef = useRef(0);
1457
- useEffect(() => {
1458
- if (live.tick === 0 || isSearching || loading || loadMoreInFlightRef.current || (!folderUid && !aggregateFolderType)) {
1472
+ /**
1473
+ * Quietly refetches the first page of whatever is listed and folds it in (see above) - the same refresh a push event makes, which a bulk action or
1474
+ * a move also makes once its rows have left, so the list is brought up to date (counts, previews) without the skeleton or losing the reader's place.
1475
+ * `listRun` is the listing the caller means: a refresh that finds another listing on screen by the time it lands is thrown away.
1476
+ */
1477
+ function refreshListQuietly(listRun = searchRunIdRef.current) {
1478
+ if (isSearching || loading || loadMoreInFlightRef.current || (!folderUid && !aggregateFolderType)) {
1459
1479
  return;
1460
1480
  }
1461
- if (!asConversations && live.folderUids) {
1462
- const shown = new Set(
1463
- aggregateFolderType
1464
- ? mailboxFolders.flatMap((entry) => entry.folders.filter((f) => f.type === aggregateFolderType).map((f) => f.uid))
1465
- : [folderUid!],
1466
- );
1467
- if (![...live.folderUids].some((uid) => shown.has(uid))) {
1468
- return;
1469
- }
1470
- }
1471
1481
  // Superseded by a newer refresh, or by any reload of the list itself (which bumps the search run id).
1472
- const listRun = searchRunIdRef.current;
1473
1482
  const myRun = ++liveRunRef.current;
1474
1483
  const isCurrent = () => searchRunIdRef.current === listRun && liveRunRef.current === myRun;
1475
1484
  void (async () => {
@@ -1514,6 +1523,22 @@ function InboxContent({ userUid }: { userUid?: string }) {
1514
1523
  // Quiet by design - see above.
1515
1524
  }
1516
1525
  })();
1526
+ }
1527
+ useEffect(() => {
1528
+ if (live.tick === 0) {
1529
+ return;
1530
+ }
1531
+ if (!asConversations && live.folderUids) {
1532
+ const shown = new Set(
1533
+ aggregateFolderType
1534
+ ? mailboxFolders.flatMap((entry) => entry.folders.filter((f) => f.type === aggregateFolderType).map((f) => f.uid))
1535
+ : [folderUid!],
1536
+ );
1537
+ if (![...live.folderUids].some((uid) => shown.has(uid))) {
1538
+ return;
1539
+ }
1540
+ }
1541
+ refreshListQuietly();
1517
1542
  }, [live.tick]);
1518
1543
 
1519
1544
  function handleSearchAllMail() {
@@ -1788,14 +1813,66 @@ function InboxContent({ userUid }: { userUid?: string }) {
1788
1813
  }
1789
1814
  }
1790
1815
 
1816
+ /**
1817
+ * Takes rows out of the list without a jolt: they collapse over `ROW_EXIT_MS` (the rows below slide up into the gap - see `collapseRow()`), then
1818
+ * `commit()` drops them from the data. `keys` are the rows' `exitingKeys`. With nothing to animate - none of them is listed, the browser can't
1819
+ * animate, or the reader prefers reduced motion - `commit()` runs at once.
1820
+ */
1821
+ function animateRowsOut(keys: string[], commit: () => void) {
1822
+ if (keys.length === 0 || !canAnimateRowExit()) {
1823
+ commit();
1824
+ return;
1825
+ }
1826
+ setExitingKeys((prev) => new Set([...prev, ...keys]));
1827
+ const timer = setTimeout(() => {
1828
+ exitTimersRef.current.delete(timer);
1829
+ commit();
1830
+ setExitingKeys((prev) => {
1831
+ const next = new Set(prev);
1832
+ keys.forEach((key) => next.delete(key));
1833
+ return next;
1834
+ });
1835
+ }, ROW_EXIT_MS);
1836
+ exitTimersRef.current.add(timer);
1837
+ }
1838
+
1839
+ /**
1840
+ * Takes the conversations whose every message is in `uids` out of the conversation list (animated), then quietly refreshes the list: a conversation
1841
+ * that keeps messages elsewhere stays, with its count and preview brought up to date by the refresh rather than by reloading the whole list.
1842
+ * `listRun` is the listing the caller acted on; if another is on screen by now there is nothing left to do.
1843
+ */
1844
+ function removeListedConversations(uids: Set<string>, listRun = searchRunIdRef.current) {
1845
+ if (searchRunIdRef.current !== listRun) {
1846
+ return;
1847
+ }
1848
+ const leaving = new Set(conversationsRef.current.filter((c) => c.messageUids.every((uid) => uids.has(uid))).map(conversationKey));
1849
+ animateRowsOut([...leaving], () => {
1850
+ if (searchRunIdRef.current !== listRun) {
1851
+ return;
1852
+ }
1853
+ setConversations((prev) => prev.filter((c) => !leaving.has(conversationKey(c))));
1854
+ // The refresh below merges into the ref, which only catches up with the state on the next render.
1855
+ conversationsRef.current = conversationsRef.current.filter((c) => !leaving.has(conversationKey(c)));
1856
+ listedOffsetRef.current = Math.max(0, listedOffsetRef.current - leaving.size);
1857
+ refreshListQuietly(listRun);
1858
+ });
1859
+ }
1860
+
1791
1861
  function removeListedMessages(uids: Set<string>) {
1792
1862
  const selectedIndex = messagesRef.current.findIndex((m) => m.uid === selectedUid);
1793
1863
  if (selectedUid && uids.has(selectedUid) && selectedIndex !== -1) {
1794
1864
  removedAnchorRef.current = selectedIndex;
1795
1865
  }
1796
- setMessages((prev) => prev.filter((m) => !uids.has(m.uid)));
1797
- listedOffsetRef.current = Math.max(0, listedOffsetRef.current - uids.size);
1798
1866
  setSelectedUid((prev) => (prev && uids.has(prev) ? null : prev));
1867
+ if (asConversations) {
1868
+ removeListedConversations(uids);
1869
+ return;
1870
+ }
1871
+ listedOffsetRef.current = Math.max(0, listedOffsetRef.current - uids.size);
1872
+ animateRowsOut(
1873
+ messagesRef.current.filter((m) => uids.has(m.uid)).map((m) => m.uid),
1874
+ () => setMessages((prev) => prev.filter((m) => !uids.has(m.uid))),
1875
+ );
1799
1876
  }
1800
1877
 
1801
1878
  function removeListedMessage(uid: string) {
@@ -1928,6 +2005,55 @@ function InboxContent({ userUid }: { userUid?: string }) {
1928
2005
  void resolveConversations(conversations);
1929
2006
  }
1930
2007
 
2008
+ /**
2009
+ * Shift+click: the keys from the anchor to `target` in `keys` (the list in the order it is displayed), entering select mode. The anchor is the
2010
+ * row last clicked or opened (`selectionAnchorRef`), else the row open in the reading pane (`openKey`), else the clicked row itself - and it is
2011
+ * pinned where it was, not moved to `target`, so a second Shift+click elsewhere re-spans from the same row.
2012
+ */
2013
+ function selectRange(keys: string[], target: string, openKey: string | null): string[] {
2014
+ const anchor = resolveAnchor(keys, selectionAnchorRef.current, openKey);
2015
+ selectionAnchorRef.current = anchor ?? target;
2016
+ setSelectMode(true);
2017
+ return rangeBetween(keys, anchor, target);
2018
+ }
2019
+
2020
+ /** Shift+click on a message row. Plain Shift makes the range the whole selection; Ctrl+Shift (`extend`) adds it to what is ticked already. */
2021
+ function selectMessageRange(message: Message, extend: boolean) {
2022
+ const range = selectRange(
2023
+ displayedMessages.map((m) => m.uid),
2024
+ message.uid,
2025
+ selectedUid,
2026
+ );
2027
+ setSelectedUids((prev) => new Set(extend ? [...prev, ...range] : range));
2028
+ }
2029
+
2030
+ /** Shift+click on a conversation row: as `selectMessageRange()`, over the rows in the order they are displayed, each resolved to its messages like a ticked one. */
2031
+ function selectConversationRange(conversation: ListedConversation, extend: boolean) {
2032
+ const keys = listedConversations.map(conversationKey);
2033
+ const openIndex = selectedRowIndex();
2034
+ const range = selectRange(keys, conversationKey(conversation), openIndex === -1 ? null : keys[openIndex]);
2035
+ setSelectedConversationIds((prev) => new Set(extend ? [...prev, ...range] : range));
2036
+ const inRange = new Set(range);
2037
+ void resolveConversations(listedConversations.filter((c) => inRange.has(conversationKey(c))));
2038
+ }
2039
+
2040
+ /** A plain click on a conversation's checkbox: ticks (or unticks) it and makes it the anchor of the next Shift+click. */
2041
+ function tickConversation(conversation: ListedConversation) {
2042
+ selectionAnchorRef.current = conversationKey(conversation);
2043
+ toggleConversationSelected(conversation);
2044
+ }
2045
+
2046
+ /** A Shift, Ctrl or Cmd click on a conversation row or its checkbox (the list hands those over rather than opening or ticking the row). */
2047
+ function handleConversationModifierClick(conversation: ListedConversation, modifiers: ClickModifiers) {
2048
+ if (modifiers.shiftKey) {
2049
+ selectConversationRange(conversation, isToggleClick(modifiers));
2050
+ return;
2051
+ }
2052
+ // Ctrl (Cmd): just this row, and select mode if the reader was not in it.
2053
+ setSelectMode(true);
2054
+ tickConversation(conversation);
2055
+ }
2056
+
1931
2057
  /**
1932
2058
  * Runs one bulk action over the current selection, then either patches the affected rows in place or
1933
2059
  * drops them (a move takes them out of the folder being listed).
@@ -1945,6 +2071,8 @@ function InboxContent({ userUid }: { userUid?: string }) {
1945
2071
  removesRows: boolean,
1946
2072
  chosen: Message[] = selectedMessages,
1947
2073
  ): Promise<boolean> {
2074
+ // The listing this acts on: the action takes a while, and the reader may have opened another folder by the time it is done.
2075
+ const listRun = searchRunIdRef.current;
1948
2076
  setBulkBusy(true);
1949
2077
  try {
1950
2078
  const updated = await action(chosen);
@@ -1961,11 +2089,16 @@ function InboxContent({ userUid }: { userUid?: string }) {
1961
2089
  }
1962
2090
  if (asConversations) {
1963
2091
  // A conversation row is a summary of its messages - its count, unread count, participants
1964
- // and preview all move when a bulk action changes or empties part of it - so the list is
1965
- // reloaded rather than patched row by row.
2092
+ // and preview all move when a bulk action changes or empties part of it - so the rows that
2093
+ // went collapse away and the list is then refetched quietly (no skeleton, nothing forgotten)
2094
+ // rather than patched row by row.
1966
2095
  setSelectedConversationIds(new Set());
1967
2096
  setConversationMessagesById({});
1968
- setRefreshKey((n) => n + 1);
2097
+ if (removesRows) {
2098
+ removeListedConversations(new Set(chosen.map((m) => m.uid)), listRun);
2099
+ } else {
2100
+ refreshListQuietly(listRun);
2101
+ }
1969
2102
  } else if (removesRows) {
1970
2103
  removeListedMessages(new Set(chosen.map((m) => m.uid)));
1971
2104
  } else {
@@ -2080,6 +2213,7 @@ function InboxContent({ userUid }: { userUid?: string }) {
2080
2213
  * (those stay listed, and the reload shows what is really there). Resolves whether anything was deleted.
2081
2214
  */
2082
2215
  async function purgeChosen(chosen: Message[]): Promise<boolean> {
2216
+ const listRun = searchRunIdRef.current;
2083
2217
  const outcome = await permanent.requestPermanentDelete(chosen);
2084
2218
  if (!outcome) {
2085
2219
  return false;
@@ -2087,7 +2221,7 @@ function InboxContent({ userUid }: { userUid?: string }) {
2087
2221
  if (asConversations) {
2088
2222
  setSelectedConversationIds(new Set());
2089
2223
  setConversationMessagesById({});
2090
- setRefreshKey((n) => n + 1);
2224
+ removeListedConversations(new Set(outcome.deleted.map((m) => m.uid)), listRun);
2091
2225
  } else {
2092
2226
  removeListedMessages(new Set(outcome.deleted.map((m) => m.uid)));
2093
2227
  if (outcome.failed.length > 0) {
@@ -2179,6 +2313,7 @@ function InboxContent({ userUid }: { userUid?: string }) {
2179
2313
 
2180
2314
  /** One message's row of the flat list - and, in search results grouped by conversation, of a group. */
2181
2315
  function renderMessageRow(message: Message) {
2316
+ const exiting = exitingKeys.has(message.uid);
2182
2317
  return (
2183
2318
  <SwipeRow
2184
2319
  as="li"
@@ -2188,9 +2323,12 @@ function InboxContent({ userUid }: { userUid?: string }) {
2188
2323
  key={message.uid}
2189
2324
  data-message-uid={message.uid}
2190
2325
  data-unread={isUnread(message) ? "true" : undefined}
2326
+ data-exiting={exiting ? "true" : undefined}
2327
+ aria-hidden={exiting ? "true" : undefined}
2328
+ inert={exiting}
2191
2329
  className={rowClass(
2192
2330
  { unread: isUnread(message), selected: message.uid === selectedUid || selectedUids.has(message.uid) },
2193
- "flex items-stretch",
2331
+ exiting ? "flex items-stretch pointer-events-none" : "flex items-stretch",
2194
2332
  )}
2195
2333
  >
2196
2334
  <UnreadBar unread={isUnread(message)} />
@@ -2199,7 +2337,8 @@ function InboxContent({ userUid }: { userUid?: string }) {
2199
2337
  <input
2200
2338
  type="checkbox"
2201
2339
  checked={selectedUids.has(message.uid)}
2202
- onChange={() => toggleSelected(message.uid)}
2340
+ // The change of a checkbox is caused by a click (or the Space key, which makes one): its modifiers are that event's.
2341
+ onChange={(event) => handleSelect(message, event.nativeEvent as MouseEvent)}
2203
2342
  aria-label={`Select ${rowSubject(message)}`}
2204
2343
  className="w-4 h-4 accent-primary"
2205
2344
  />
@@ -2210,7 +2349,7 @@ function InboxContent({ userUid }: { userUid?: string }) {
2210
2349
  <button
2211
2350
  type="button"
2212
2351
  data-row-open
2213
- onClick={() => handleSelect(message)}
2352
+ onClick={(event) => handleSelect(message, event)}
2214
2353
  className={["w-full text-left px-4 py-3", ROW_FOCUS_CLASS].join(" ")}
2215
2354
  >
2216
2355
  <UnreadLabel unread={isUnread(message)} />
@@ -2266,6 +2405,8 @@ function InboxContent({ userUid }: { userUid?: string }) {
2266
2405
  /** Search results arranged by conversation: the messages that matched, grouped under the conversation each belongs to, in the order of the
2267
2406
  * first match of each - the order the results are ranked in. `null` when the list is not showing grouped results. */
2268
2407
  const resultGroups = groupedResults ? groupByConversation(messages) : null;
2408
+ /** The messages in the order the list shows them - grouped results are listed group by group - which is the order a Shift+click range runs in. */
2409
+ const displayedMessages = resultGroups ? resultGroups.flatMap((group) => group.messages) : messages;
2269
2410
 
2270
2411
  /** The search box: in the list on a desktop (flat lists only), in the shell's header beside the folders button on a phone. */
2271
2412
  const searchField = (
@@ -2280,7 +2421,22 @@ function InboxContent({ userUid }: { userUid?: string }) {
2280
2421
  />
2281
2422
  );
2282
2423
 
2283
- function handleSelect(message: Message) {
2424
+ /**
2425
+ * A click on a message row (or its checkbox), or the keyboard moving the selection to it (no `modifiers`). Shift+click selects the range from the
2426
+ * anchor; Ctrl/Cmd+click toggles just this row, entering select mode if needed (Ctrl+Shift adds the range to the selection instead of replacing it);
2427
+ * a plain click ticks the row in select mode and opens it otherwise.
2428
+ */
2429
+ function handleSelect(message: Message, modifiers?: ClickModifiers) {
2430
+ if (modifiers?.shiftKey) {
2431
+ selectMessageRange(message, isToggleClick(modifiers));
2432
+ return;
2433
+ }
2434
+ selectionAnchorRef.current = message.uid;
2435
+ if (isToggleClick(modifiers)) {
2436
+ setSelectMode(true);
2437
+ toggleSelected(message.uid);
2438
+ return;
2439
+ }
2284
2440
  if (selectMode) {
2285
2441
  toggleSelected(message.uid);
2286
2442
  return;
@@ -2319,6 +2475,7 @@ function InboxContent({ userUid }: { userUid?: string }) {
2319
2475
  /** Opens a conversation in the reading pane, positioned at one of its messages: the one a child row
2320
2476
  * stands for, or the latest for a parent row. The thread pane loads the thread itself. */
2321
2477
  function handleOpenConversation(conversation: ListedConversation, uid: string) {
2478
+ selectionAnchorRef.current = conversationKey(conversation);
2322
2479
  if (selectMode) {
2323
2480
  // Same rule as `handleSelect()` for a message row: while selecting, a row's own button ticks
2324
2481
  // the row rather than opening it.
@@ -2346,7 +2503,15 @@ function InboxContent({ userUid }: { userUid?: string }) {
2346
2503
  /** What the keyboard acts on exists: the ticked rows in select mode, else the message (or conversation) open in the reading pane. */
2347
2504
  const keyboardTargetExists = selectMode ? selectedMessages.length > 0 : threadPane ? openThread !== null : selected !== null;
2348
2505
  const rowCount = inConversations ? listedConversations.length : messages.length;
2349
- const canMoveSelection = !selectMode && !isMobile && !loading && rowCount > 0;
2506
+ // Not while rows are collapsing out of the list: their indexes are about to shift.
2507
+ const canMoveSelection = !selectMode && !isMobile && !loading && rowCount > 0 && exitingKeys.size === 0;
2508
+
2509
+ // Starts the collapse of the rows that have just been marked as leaving (see `animateRowsOut()`).
2510
+ useLayoutEffect(() => {
2511
+ if (exitingKeys.size > 0) {
2512
+ scrollContainerRef.current!.querySelectorAll<HTMLElement>("[data-exiting]").forEach((row) => collapseRow(row));
2513
+ }
2514
+ }, [exitingKeys]);
2350
2515
 
2351
2516
  /** The type of a message's folder - looked for in every mailbox's, as a search over several has messages from each. */
2352
2517
  function folderTypeOf(folderUidOfMessage: string): Folder["type"] | undefined {
@@ -2623,344 +2788,358 @@ function InboxContent({ userUid }: { userUid?: string }) {
2623
2788
 
2624
2789
  return (
2625
2790
  <div className="flex h-full min-h-0">
2626
- <div
2627
- ref={scrollContainerRef}
2628
- // Remembered as it moves (not when the list is left: by then React has already detached the element), so
2629
- // the folder - or Mail, after another app - comes back where it was.
2630
- onScroll={(event) => saveListScroll(listKey, event.currentTarget.scrollTop)}
2631
- className="w-full md:w-96 shrink-0 md:border-r border-border overflow-y-auto"
2632
- >
2633
- {selectMode ? (
2634
- <MailSelectionBar
2635
- selected={selectedMessages}
2636
- listed={messages}
2637
- totals={
2638
- asConversations
2639
- ? { selected: selectedConversationIds.size, listed: conversations.length, noun: "conversation" }
2640
- : undefined
2641
- }
2642
- onSelectAll={() =>
2643
- asConversations
2644
- ? selectAllConversations()
2645
- : setSelectedUids(new Set(messages.map((m) => m.uid)))
2646
- }
2647
- onClearSelection={() =>
2648
- asConversations ? setSelectedConversationIds(new Set()) : setSelectedUids(new Set())
2649
- }
2650
- onCancel={leaveSelectMode}
2651
- folders={foldersOf(selectionMailboxUid)}
2652
- currentFolderUid={folderUid}
2653
- labels={mailboxLabels}
2654
- mailboxUid={selectionMailboxUid}
2655
- moveDisabledReason={moveDisabledReason}
2656
- labelsDisabledReason={labelsDisabledReason}
2657
- onLabelCreated={(label) => setMailboxLabels((prev) => [...prev, label])}
2658
- onFolderCreated={onFolderCreated}
2659
- onApplyLabels={applyLabelsToSelection}
2660
- onSetRead={(read) =>
2661
- void runBulkAction(
2662
- // Optimistic: the rows and the folder badges change now, and change back if the server refuses.
2663
- (chosen) => setReadStateMany(chosen, read, { patch: patchListedMessage, track: trackMessageChange }),
2664
- false,
2665
- )
2666
- }
2667
- onSetFlagged={(flagged) => void runBulkAction((chosen) => setMessagesFlagged(chosen, flagged, client), false)}
2668
- shortcuts={keyboardActions}
2669
- onArchive={() => void runBulkAction(bulkArchive, true)}
2670
- onMoveTo={async (targetFolderUid) => {
2671
- await runBulkAction((chosen) => moveMessages(chosen, targetFolderUid, client), true);
2672
- }}
2673
- onReportJunk={() => void moveSelectionToType("junk", "Junk Email")}
2674
- onDelete={() =>
2675
- void (deletesPermanently
2676
- ? purgeChosen(selectedMessages)
2677
- : // A mix (search results from several folders) moves only what is not in Deleted Items yet.
2678
- moveSelectionToType("deleted_items", "Deleted Items", selectedMessages.filter((m) => !inDeletedItems(m))))
2679
- }
2680
- deletesPermanently={deletesPermanently}
2681
- busy={bulkBusy || resolvingSelection > 0 || permanent.busy}
2682
- />
2683
- ) : (
2684
- <MailListToolbar
2685
- sortBy={preferences.sortBy}
2686
- sortOrder={preferences.sortOrder}
2687
- filter={preferences.filter}
2688
- labelUids={preferences.labelUids}
2689
- labels={mailboxLabels}
2690
- mailboxUid={activeMailboxUid}
2691
- onLabelCreated={(label) => setMailboxLabels((prev) => [...prev, label])}
2692
- onLabelUidsChange={(nextLabelUids) => updatePreferences({ labelUids: nextLabelUids })}
2693
- showAsConversations={preferences.showAsConversations}
2694
- onSortChange={(sortBy, sortOrder) => updatePreferences({ sortBy, sortOrder })}
2695
- onFilterChange={(filter) => updatePreferences({ filter })}
2696
- onShowAsConversationsChange={(showAsConversations) => updatePreferences({ showAsConversations })}
2697
- selectMode={selectMode}
2698
- onSelectModeChange={setSelectMode}
2699
- offerClassificationFilters={offerClassificationFilters}
2700
- filterDisabled={isSearching}
2701
- filterDisabledReason="Filters don't apply to search results"
2702
- sortKeysDisabled={isSearching || !!aggregateFolderType}
2703
- // A conversation row is a thread summary, so only some of the keys have anything to
2704
- // order by - the rest stay pickable and are applied to the rows already fetched.
2705
- unavailableSortKeys={asConversations ? CONVERSATION_SORT_UNAVAILABLE : undefined}
2706
- sortKeysNote={
2707
- isSearching
2708
- ? "Search results are ranked by relevance rather than sorted."
2709
- : aggregateFolderType
2710
- ? "This view merges the newest mail from every mailbox and is always listed by date."
2711
- : asConversations
2712
- ? CONVERSATION_SORT_NOTE
2791
+ {/* The list column: the toolbar (or the selection bar), the search box and the Focused/Other tabs are a fixed block at the top and only
2792
+ the rows below scroll, each of the three columns (folders, list, reading pane) being its own scroller of the window's height. */}
2793
+ <div data-testid="mail-list-column" className="w-full md:w-96 shrink-0 md:border-r border-border flex flex-col min-h-0">
2794
+ <div data-testid="mail-list-header" className="shrink-0">
2795
+ {selectMode ? (
2796
+ <MailSelectionBar
2797
+ selected={selectedMessages}
2798
+ listed={messages}
2799
+ totals={
2800
+ asConversations
2801
+ ? { selected: selectedConversationIds.size, listed: conversations.length, noun: "conversation" }
2713
2802
  : undefined
2714
- }
2715
- selectDisabled={loading || listedRowCount === 0}
2716
- selectDisabledReason={loading ? "Wait for this folder to finish loading" : "There is nothing here to select"}
2717
- />
2718
- )}
2719
- {!isMobile && <div className="p-2 border-b border-border">{searchField}</div>}
2720
- {isMobile && mobileSearchSlot && createPortal(searchField, mobileSearchSlot)}
2721
- {emptiableFolder && !selectMode && (
2722
- <EmptyFolderBar
2723
- folderName={emptiableFolder.name}
2724
- count={emptiableCount}
2725
- disabled={!!emptyDisabledReason || permanent.busy || bulkBusy}
2726
- disabledReason={emptyDisabledReason}
2727
- onEmpty={() => void emptyListedFolder(emptiableFolder, emptiableCount)}
2728
- />
2729
- )}
2730
- {permanent.dialog}
2731
- {/* Two tabs, as Outlook has: Focused and Other. There is no "All" tab - the whole Inbox is
2732
- still one pick away, in the Filter menu, which is where every other named filter lives
2733
- and the only place that can show which of them is really in force. A stored `all` (or
2734
- Unread, Flagged, ...) therefore still lists what it always did, with neither tab
2735
- pressed, rather than being migrated into one of these two halves behind the reader's
2736
- back - see `MAIL_LIST_FILTERS`, which still offers it. */}
2737
- {offerClassificationFilters && (
2738
- <div className="flex border-b border-border text-xs">
2739
- {MAIL_LIST_CLASSIFICATION_FILTERS.map(({ value, label }) => (
2740
- <button
2741
- key={value}
2742
- type="button"
2743
- aria-pressed={preferences.filter === value}
2744
- onClick={() => updatePreferences({ filter: value })}
2745
- className={[
2746
- "flex-1 py-1.5 font-semibold",
2747
- preferences.filter === value
2748
- ? "text-primary-dark border-b-2 border-primary-dark"
2749
- : "text-text-muted",
2750
- ].join(" ")}
2751
- >
2752
- {label}
2753
- </button>
2754
- ))}
2755
- </div>
2756
- )}
2757
-
2758
- {isSearching && (
2759
- <div className="px-4 py-1.5 text-xs text-text-muted border-b border-border flex items-center justify-between gap-2">
2760
- {/* §_Progressive Results_: "Never show a hard count until every tier has reported.
2761
- Display n of ??, or omit the count. A settled count is the signal that ordering
2762
- is final." */}
2763
- <span className="flex flex-col">
2764
- <span>
2765
- {tier1Done && tier2Done && tier3Done
2766
- ? `${messages.length} result${messages.length === 1 ? "" : "s"}`
2767
- : `${messages.length} of ??`}
2768
- </span>
2769
- {crossMailbox && <span data-testid="search-scope">All mailboxes</span>}
2770
- </span>
2771
- <span className="flex flex-col items-end gap-0.5">
2772
- {tier2Done && !searchAllMail && (
2803
+ }
2804
+ onSelectAll={() =>
2805
+ asConversations
2806
+ ? selectAllConversations()
2807
+ : setSelectedUids(new Set(messages.map((m) => m.uid)))
2808
+ }
2809
+ onClearSelection={() =>
2810
+ asConversations ? setSelectedConversationIds(new Set()) : setSelectedUids(new Set())
2811
+ }
2812
+ onCancel={leaveSelectMode}
2813
+ folders={foldersOf(selectionMailboxUid)}
2814
+ currentFolderUid={folderUid}
2815
+ labels={mailboxLabels}
2816
+ mailboxUid={selectionMailboxUid}
2817
+ moveDisabledReason={moveDisabledReason}
2818
+ labelsDisabledReason={labelsDisabledReason}
2819
+ onLabelCreated={(label) => setMailboxLabels((prev) => [...prev, label])}
2820
+ onFolderCreated={onFolderCreated}
2821
+ onApplyLabels={applyLabelsToSelection}
2822
+ onSetRead={(read) =>
2823
+ void runBulkAction(
2824
+ // Optimistic: the rows and the folder badges change now, and change back if the server refuses.
2825
+ (chosen) => setReadStateMany(chosen, read, { patch: patchListedMessage, track: trackMessageChange }),
2826
+ false,
2827
+ )
2828
+ }
2829
+ onSetFlagged={(flagged) => void runBulkAction((chosen) => setMessagesFlagged(chosen, flagged, client), false)}
2830
+ shortcuts={keyboardActions}
2831
+ onArchive={() => void runBulkAction(bulkArchive, true)}
2832
+ onMoveTo={async (targetFolderUid) => {
2833
+ await runBulkAction((chosen) => moveMessages(chosen, targetFolderUid, client), true);
2834
+ }}
2835
+ onReportJunk={() => void moveSelectionToType("junk", "Junk Email")}
2836
+ onDelete={() =>
2837
+ void (deletesPermanently
2838
+ ? purgeChosen(selectedMessages)
2839
+ : // A mix (search results from several folders) moves only what is not in Deleted Items yet.
2840
+ moveSelectionToType("deleted_items", "Deleted Items", selectedMessages.filter((m) => !inDeletedItems(m))))
2841
+ }
2842
+ deletesPermanently={deletesPermanently}
2843
+ busy={bulkBusy || resolvingSelection > 0 || permanent.busy}
2844
+ />
2845
+ ) : (
2846
+ <MailListToolbar
2847
+ sortBy={preferences.sortBy}
2848
+ sortOrder={preferences.sortOrder}
2849
+ filter={preferences.filter}
2850
+ labelUids={preferences.labelUids}
2851
+ labels={mailboxLabels}
2852
+ mailboxUid={activeMailboxUid}
2853
+ onLabelCreated={(label) => setMailboxLabels((prev) => [...prev, label])}
2854
+ onLabelUidsChange={(nextLabelUids) => updatePreferences({ labelUids: nextLabelUids })}
2855
+ showAsConversations={preferences.showAsConversations}
2856
+ onSortChange={(sortBy, sortOrder) => updatePreferences({ sortBy, sortOrder })}
2857
+ onFilterChange={(filter) => updatePreferences({ filter })}
2858
+ onShowAsConversationsChange={(showAsConversations) => updatePreferences({ showAsConversations })}
2859
+ selectMode={selectMode}
2860
+ onSelectModeChange={setSelectMode}
2861
+ offerClassificationFilters={offerClassificationFilters}
2862
+ filterDisabled={isSearching}
2863
+ filterDisabledReason="Filters don't apply to search results"
2864
+ sortKeysDisabled={isSearching || !!aggregateFolderType}
2865
+ // A conversation row is a thread summary, so only some of the keys have anything to
2866
+ // order by - the rest stay pickable and are applied to the rows already fetched.
2867
+ unavailableSortKeys={asConversations ? CONVERSATION_SORT_UNAVAILABLE : undefined}
2868
+ sortKeysNote={
2869
+ isSearching
2870
+ ? "Search results are ranked by relevance rather than sorted."
2871
+ : aggregateFolderType
2872
+ ? "This view merges the newest mail from every mailbox and is always listed by date."
2873
+ : asConversations
2874
+ ? CONVERSATION_SORT_NOTE
2875
+ : undefined
2876
+ }
2877
+ selectDisabled={loading || listedRowCount === 0}
2878
+ selectDisabledReason={loading ? "Wait for this folder to finish loading" : "There is nothing here to select"}
2879
+ />
2880
+ )}
2881
+ {!isMobile && <div className="p-2 border-b border-border">{searchField}</div>}
2882
+ {isMobile && mobileSearchSlot && createPortal(searchField, mobileSearchSlot)}
2883
+ {emptiableFolder && !selectMode && (
2884
+ <EmptyFolderBar
2885
+ folderName={emptiableFolder.name}
2886
+ count={emptiableCount}
2887
+ disabled={!!emptyDisabledReason || permanent.busy || bulkBusy}
2888
+ disabledReason={emptyDisabledReason}
2889
+ onEmpty={() => void emptyListedFolder(emptiableFolder, emptiableCount)}
2890
+ />
2891
+ )}
2892
+ {permanent.dialog}
2893
+ {/* Two tabs, as Outlook has: Focused and Other. There is no "All" tab - the whole Inbox is
2894
+ still one pick away, in the Filter menu, which is where every other named filter lives
2895
+ and the only place that can show which of them is really in force. A stored `all` (or
2896
+ Unread, Flagged, ...) therefore still lists what it always did, with neither tab
2897
+ pressed, rather than being migrated into one of these two halves behind the reader's
2898
+ back - see `MAIL_LIST_FILTERS`, which still offers it. */}
2899
+ {offerClassificationFilters && (
2900
+ <div className="flex border-b border-border text-xs">
2901
+ {MAIL_LIST_CLASSIFICATION_FILTERS.map(({ value, label }) => (
2773
2902
  <button
2903
+ key={value}
2774
2904
  type="button"
2775
- onClick={handleSearchAllMail}
2776
- title={
2777
- crossMailbox
2778
- ? "Also search encrypted mail from before each mailbox's local index begins"
2779
- : undefined
2780
- }
2781
- className="text-primary-dark hover:underline font-medium shrink-0"
2905
+ aria-pressed={preferences.filter === value}
2906
+ onClick={() => updatePreferences({ filter: value })}
2907
+ className={[
2908
+ "flex-1 py-1.5 font-semibold",
2909
+ preferences.filter === value
2910
+ ? "text-primary-dark border-b-2 border-primary-dark"
2911
+ : "text-text-muted",
2912
+ ].join(" ")}
2782
2913
  >
2783
- {/* "All mail" already means every mailbox here, so this says what it adds. */}
2784
- {crossMailbox ? "Search older encrypted mail" : "Search all mail"}
2914
+ {label}
2785
2915
  </button>
2786
- )}
2787
- {widenable && (
2916
+ ))}
2917
+ </div>
2918
+ )}
2919
+ </div>
2920
+ <div
2921
+ ref={scrollContainerRef}
2922
+ data-testid="mail-list-scroll"
2923
+ // Remembered as it moves (not when the list is left: by then React has already detached the element), so
2924
+ // the folder - or Mail, after another app - comes back where it was.
2925
+ onScroll={(event) => saveListScroll(listKey, event.currentTarget.scrollTop)}
2926
+ // A Shift+click selects a range: without this the browser would also select the text between the two rows.
2927
+ onMouseDown={(event) => {
2928
+ if (event.shiftKey) {
2929
+ event.preventDefault();
2930
+ }
2931
+ }}
2932
+ className="flex-1 min-h-0 overflow-y-auto"
2933
+ >
2934
+ {isSearching && (
2935
+ <div className="px-4 py-1.5 text-xs text-text-muted border-b border-border flex items-center justify-between gap-2">
2936
+ {/* §_Progressive Results_: "Never show a hard count until every tier has reported.
2937
+ Display n of ??, or omit the count. A settled count is the signal that ordering
2938
+ is final." */}
2939
+ <span className="flex flex-col">
2940
+ <span>
2941
+ {tier1Done && tier2Done && tier3Done
2942
+ ? `${messages.length} result${messages.length === 1 ? "" : "s"}`
2943
+ : `${messages.length} of ??`}
2944
+ </span>
2945
+ {crossMailbox && <span data-testid="search-scope">All mailboxes</span>}
2946
+ </span>
2947
+ <span className="flex flex-col items-end gap-0.5">
2948
+ {tier2Done && !searchAllMail && (
2949
+ <button
2950
+ type="button"
2951
+ onClick={handleSearchAllMail}
2952
+ title={
2953
+ crossMailbox
2954
+ ? "Also search encrypted mail from before each mailbox's local index begins"
2955
+ : undefined
2956
+ }
2957
+ className="text-primary-dark hover:underline font-medium shrink-0"
2958
+ >
2959
+ {/* "All mail" already means every mailbox here, so this says what it adds. */}
2960
+ {crossMailbox ? "Search older encrypted mail" : "Search all mail"}
2961
+ </button>
2962
+ )}
2963
+ {widenable && (
2964
+ <button
2965
+ type="button"
2966
+ onClick={() => setSearchAllMailboxes(!searchAllMailboxes)}
2967
+ className="text-primary-dark hover:underline font-medium shrink-0"
2968
+ >
2969
+ {searchAllMailboxes ? "Search this mailbox only" : "Search all mailboxes"}
2970
+ </button>
2971
+ )}
2972
+ </span>
2973
+ </div>
2974
+ )}
2975
+ {crossMailbox && isSearching && searchableMailboxes.length > searchedMailboxes.length && (
2976
+ <div role="status" className="px-4 py-1.5 text-xs text-text-muted border-b border-border">
2977
+ Searched {searchedMailboxes.length} of {searchableMailboxes.length} mailboxes - the most that are searched at once.
2978
+ </div>
2979
+ )}
2980
+ {crossMailbox && isSearching && searchFailures.length > 0 && (
2981
+ <div role="status" className="px-4 py-1.5 text-xs text-text-muted border-b border-border bg-surface-alt">
2982
+ Some results may be missing: {describeFailures(searchFailures)}
2983
+ </div>
2984
+ )}
2985
+ {isSearching && !crossMailbox && coverage?.indexedFrom && (
2986
+ <div className="px-4 py-1.5 text-xs text-text-muted border-b border-border">
2987
+ Local search covers messages back to {new Date(coverage.indexedFrom).toLocaleDateString()}
2988
+ {coverage.building ? " (still building)" : ""}
2989
+ {searchAllMail
2990
+ ? " - searching everything, not just recent mail."
2991
+ : " - older encrypted mail is still searched, just slower."}
2992
+ </div>
2993
+ )}
2994
+ {isSearching && crossMailbox && tier2Done && serverOnlyMailboxes.length > 0 && (
2995
+ <div className="px-4 py-1.5 text-xs text-text-muted border-b border-border">
2996
+ There is no local index on this device for {serverOnlyMailboxes.map((mb) => mb.displayName).join(", ")}: its encrypted mail is searched
2997
+ through the server instead, which is slower and looks at a limited number of messages.
2998
+ </div>
2999
+ )}
3000
+ {isSearching && crossMailbox && lockedSearchMailboxes.length > 0 && (
3001
+ <div className="px-4 py-2 border-b border-border bg-surface-alt flex flex-col gap-1">
3002
+ {unlockableSearchMailboxes.length > 0 && (
2788
3003
  <button
2789
3004
  type="button"
2790
- onClick={() => setSearchAllMailboxes(!searchAllMailboxes)}
2791
- className="text-primary-dark hover:underline font-medium shrink-0"
3005
+ onClick={handleUnlockSearch}
3006
+ className="inline-flex items-center gap-1 text-xs font-medium text-primary-dark hover:underline"
2792
3007
  >
2793
- {searchAllMailboxes ? "Search this mailbox only" : "Search all mailboxes"}
3008
+ <HiOutlineLockClosed size={12} aria-hidden="true" />
3009
+ Unlock to include encrypted messages from {unlockableSearchMailboxes.map((mb) => mb.displayName).join(", ")}
2794
3010
  </button>
2795
3011
  )}
2796
- </span>
2797
- </div>
2798
- )}
2799
- {crossMailbox && isSearching && searchableMailboxes.length > searchedMailboxes.length && (
2800
- <div role="status" className="px-4 py-1.5 text-xs text-text-muted border-b border-border">
2801
- Searched {searchedMailboxes.length} of {searchableMailboxes.length} mailboxes - the most that are searched at once.
2802
- </div>
2803
- )}
2804
- {crossMailbox && isSearching && searchFailures.length > 0 && (
2805
- <div role="status" className="px-4 py-1.5 text-xs text-text-muted border-b border-border bg-surface-alt">
2806
- Some results may be missing: {describeFailures(searchFailures)}
2807
- </div>
2808
- )}
2809
- {isSearching && !crossMailbox && coverage?.indexedFrom && (
2810
- <div className="px-4 py-1.5 text-xs text-text-muted border-b border-border">
2811
- Local search covers messages back to {new Date(coverage.indexedFrom).toLocaleDateString()}
2812
- {coverage.building ? " (still building)" : ""}
2813
- {searchAllMail
2814
- ? " - searching everything, not just recent mail."
2815
- : " - older encrypted mail is still searched, just slower."}
2816
- </div>
2817
- )}
2818
- {isSearching && crossMailbox && tier2Done && serverOnlyMailboxes.length > 0 && (
2819
- <div className="px-4 py-1.5 text-xs text-text-muted border-b border-border">
2820
- There is no local index on this device for {serverOnlyMailboxes.map((mb) => mb.displayName).join(", ")}: its encrypted mail is searched
2821
- through the server instead, which is slower and looks at a limited number of messages.
2822
- </div>
2823
- )}
2824
- {isSearching && crossMailbox && lockedSearchMailboxes.length > 0 && (
2825
- <div className="px-4 py-2 border-b border-border bg-surface-alt flex flex-col gap-1">
2826
- {unlockableSearchMailboxes.length > 0 && (
3012
+ {sharedLockedSearchMailboxes.length > 0 && (
3013
+ <p className="text-xs text-text-muted">
3014
+ Encrypted messages in {sharedLockedSearchMailboxes.map((mb) => mb.displayName).join(", ")} are not included: only the
3015
+ mailbox&rsquo;s owner can unlock them.
3016
+ </p>
3017
+ )}
3018
+ </div>
3019
+ )}
3020
+ {isSearching && !crossMailbox && !getUnlockedKeys(mailboxUid!) && (
3021
+ <div className="px-4 py-2 border-b border-border bg-surface-alt">
2827
3022
  <button
2828
3023
  type="button"
2829
3024
  onClick={handleUnlockSearch}
2830
3025
  className="inline-flex items-center gap-1 text-xs font-medium text-primary-dark hover:underline"
2831
3026
  >
2832
3027
  <HiOutlineLockClosed size={12} aria-hidden="true" />
2833
- Unlock to include encrypted messages from {unlockableSearchMailboxes.map((mb) => mb.displayName).join(", ")}
3028
+ Unlock to include encrypted messages in these results
2834
3029
  </button>
2835
- )}
2836
- {sharedLockedSearchMailboxes.length > 0 && (
2837
- <p className="text-xs text-text-muted">
2838
- Encrypted messages in {sharedLockedSearchMailboxes.map((mb) => mb.displayName).join(", ")} are not included: only the
2839
- mailbox&rsquo;s owner can unlock them.
2840
- </p>
2841
- )}
2842
- </div>
2843
- )}
2844
- {isSearching && !crossMailbox && !getUnlockedKeys(mailboxUid!) && (
2845
- <div className="px-4 py-2 border-b border-border bg-surface-alt">
2846
- <button
2847
- type="button"
2848
- onClick={handleUnlockSearch}
2849
- className="inline-flex items-center gap-1 text-xs font-medium text-primary-dark hover:underline"
2850
- >
2851
- <HiOutlineLockClosed size={12} aria-hidden="true" />
2852
- Unlock to include encrypted messages in these results
2853
- </button>
2854
- </div>
2855
- )}
2856
- {!isSearching && !asConversations && undecryptedEncryptedUids.length > 0 && !getUnlockedKeys(activeMailboxUid) && (
2857
- <div className="px-4 py-2 border-b border-border bg-surface-alt">
2858
- <button
2859
- type="button"
2860
- onClick={handleUnlockList}
2861
- className="inline-flex items-center gap-1 text-xs font-medium text-primary-dark hover:underline"
2862
- >
2863
- <HiOutlineLockClosed size={12} aria-hidden="true" />
2864
- Unlock to show {undecryptedEncryptedUids.length === 1 ? "an encrypted message's" : "encrypted messages'"} subject
2865
- </button>
2866
- </div>
2867
- )}
2868
-
2869
- {error && (
2870
- <div className="p-4">
2871
- <Alert>{error}</Alert>
2872
- </div>
2873
- )}
3030
+ </div>
3031
+ )}
3032
+ {!isSearching && !asConversations && undecryptedEncryptedUids.length > 0 && !getUnlockedKeys(activeMailboxUid) && (
3033
+ <div className="px-4 py-2 border-b border-border bg-surface-alt">
3034
+ <button
3035
+ type="button"
3036
+ onClick={handleUnlockList}
3037
+ className="inline-flex items-center gap-1 text-xs font-medium text-primary-dark hover:underline"
3038
+ >
3039
+ <HiOutlineLockClosed size={12} aria-hidden="true" />
3040
+ Unlock to show {undecryptedEncryptedUids.length === 1 ? "an encrypted message's" : "encrypted messages'"} subject
3041
+ </button>
3042
+ </div>
3043
+ )}
2874
3044
 
2875
- {loading ? (
2876
- // A skeleton of rows rather than a line of text: the list keeps its shape while a folder that was not shown a
2877
- // moment ago loads (one that was is shown at once, from its snapshot).
2878
- <div role="status" aria-busy="true" className="p-4">
2879
- <span className="sr-only">Loading&hellip;</span>
2880
- <SkeletonList count={8} />
2881
- </div>
2882
- ) : asConversations ? (
2883
- <>
2884
- <ConversationList
2885
- conversations={listedConversations}
2886
- newestFirst={preferences.sortBy === "date" && preferences.sortOrder === "desc"}
2887
- mailboxUid={activeMailboxUid}
2888
- selectedUid={selectedUid}
2889
- messageOverrides={conversationPatches}
2890
- onMeetingResponded={patchListedMessage}
2891
- onOpenMessage={handleOpenConversation}
2892
- selectMode={selectMode}
2893
- selectedConversationIds={selectedConversationIds}
2894
- onToggleSelected={toggleConversationSelected}
2895
- swipe={{
2896
- enabled: swipeEnabled,
2897
- onArchive: swipeArchive,
2898
- onMove: (conversation) => setMoveDialog({ conversation }),
2899
- }}
2900
- />
2901
- {hasMore && !rowCapReached && (
2902
- <div ref={setSentinel} data-testid="load-more-sentinel" className="p-4 text-center text-xs text-text-muted">
2903
- {loadMoreStatus}
2904
- </div>
2905
- )}
2906
- {rowCapReached && (
2907
- <p className="p-4 text-center text-xs text-text-muted">
2908
- Showing the most recent {rowCap} conversations &mdash; refine your search or filters to see more.
2909
- </p>
2910
- )}
2911
- </>
2912
- ) : messages.length === 0 ? (
2913
- <>
2914
- <p className="p-4 text-sm text-text-muted">
2915
- {isSearching
2916
- ? `No messages match "${searchQuery}".`
2917
- : effectiveFilter === "all"
2918
- ? "No messages in this folder."
2919
- : "No messages here."}
2920
- </p>
2921
- {/* Still offered while a filter hides every loaded row - what it's looking for may be
2922
- on a later page. */}
2923
- {hasMore && (
2924
- <div ref={setSentinel} data-testid="load-more-sentinel" className="p-4 text-center text-xs text-text-muted">
2925
- {loadMoreStatus}
2926
- </div>
2927
- )}
2928
- </>
2929
- ) : (
2930
- <>
2931
- <ul className={swipeEnabled ? "overflow-x-clip" : undefined}>
2932
- {resultGroups
2933
- ? resultGroups.map((group) => (
2934
- <li key={`${group.mailboxUid}\u0000${group.id}`} data-search-group={group.id}>
2935
- <div className="px-4 py-1.5 bg-surface-alt border-b border-border text-xs text-text-muted flex items-center justify-between gap-2">
2936
- <span className="truncate font-semibold">{rowSubject(group.messages[0])}</span>
2937
- <span className="shrink-0">
2938
- {group.messages.length} matching message{group.messages.length === 1 ? "" : "s"}
2939
- </span>
2940
- </div>
2941
- <ul>{group.messages.map(renderMessageRow)}</ul>
2942
- </li>
2943
- ))
2944
- : messages.map(renderMessageRow)}
2945
- </ul>
2946
- {hasMore && !rowCapReached && (
2947
- <div ref={setSentinel} data-testid="load-more-sentinel" className="p-4 text-center text-xs text-text-muted">
2948
- {loadMoreStatus}
2949
- </div>
2950
- )}
2951
- {rowCapReached && (
2952
- <p className="p-4 text-center text-xs text-text-muted">
2953
- Showing the most recent {rowCap} messages &mdash; refine your search or filters to see more.
2954
- </p>
2955
- )}
2956
- {aggregateFolderType && !isSearching && (
2957
- <p className="p-4 text-center text-xs text-text-muted">
2958
- Showing the most recent mail from each mailbox. Open a specific mailbox&rsquo;s folder to
2959
- see older mail.
3045
+ {error && (
3046
+ <div className="p-4">
3047
+ <Alert>{error}</Alert>
3048
+ </div>
3049
+ )}
3050
+
3051
+ {loading ? (
3052
+ // A skeleton of rows rather than a line of text: the list keeps its shape while a folder that was not shown a
3053
+ // moment ago loads (one that was is shown at once, from its snapshot).
3054
+ <div role="status" aria-busy="true" className="p-4">
3055
+ <span className="sr-only">Loading&hellip;</span>
3056
+ <SkeletonList count={8} />
3057
+ </div>
3058
+ ) : asConversations ? (
3059
+ <>
3060
+ <ConversationList
3061
+ conversations={listedConversations}
3062
+ newestFirst={preferences.sortBy === "date" && preferences.sortOrder === "desc"}
3063
+ mailboxUid={activeMailboxUid}
3064
+ selectedUid={selectedUid}
3065
+ messageOverrides={conversationPatches}
3066
+ onMeetingResponded={patchListedMessage}
3067
+ onOpenMessage={handleOpenConversation}
3068
+ selectMode={selectMode}
3069
+ selectedConversationIds={selectedConversationIds}
3070
+ onToggleSelected={tickConversation}
3071
+ onSelectWithModifier={handleConversationModifierClick}
3072
+ exitingKeys={exitingKeys}
3073
+ swipe={{
3074
+ enabled: swipeEnabled,
3075
+ onArchive: swipeArchive,
3076
+ onMove: (conversation) => setMoveDialog({ conversation }),
3077
+ }}
3078
+ />
3079
+ {hasMore && !rowCapReached && (
3080
+ <div ref={setSentinel} data-testid="load-more-sentinel" className="p-4 text-center text-xs text-text-muted">
3081
+ {loadMoreStatus}
3082
+ </div>
3083
+ )}
3084
+ {rowCapReached && (
3085
+ <p className="p-4 text-center text-xs text-text-muted">
3086
+ Showing the most recent {rowCap} conversations &mdash; refine your search or filters to see more.
3087
+ </p>
3088
+ )}
3089
+ </>
3090
+ ) : messages.length === 0 ? (
3091
+ <>
3092
+ <p className="p-4 text-sm text-text-muted">
3093
+ {isSearching
3094
+ ? `No messages match "${searchQuery}".`
3095
+ : effectiveFilter === "all"
3096
+ ? "No messages in this folder."
3097
+ : "No messages here."}
2960
3098
  </p>
2961
- )}
2962
- </>
2963
- )}
3099
+ {/* Still offered while a filter hides every loaded row - what it's looking for may be
3100
+ on a later page. */}
3101
+ {hasMore && (
3102
+ <div ref={setSentinel} data-testid="load-more-sentinel" className="p-4 text-center text-xs text-text-muted">
3103
+ {loadMoreStatus}
3104
+ </div>
3105
+ )}
3106
+ </>
3107
+ ) : (
3108
+ <>
3109
+ <ul className={swipeEnabled ? "overflow-x-clip" : undefined}>
3110
+ {resultGroups
3111
+ ? resultGroups.map((group) => (
3112
+ <li key={`${group.mailboxUid}\u0000${group.id}`} data-search-group={group.id}>
3113
+ <div className="px-4 py-1.5 bg-surface-alt border-b border-border text-xs text-text-muted flex items-center justify-between gap-2">
3114
+ <span className="truncate font-semibold">{rowSubject(group.messages[0])}</span>
3115
+ <span className="shrink-0">
3116
+ {group.messages.length} matching message{group.messages.length === 1 ? "" : "s"}
3117
+ </span>
3118
+ </div>
3119
+ <ul>{group.messages.map(renderMessageRow)}</ul>
3120
+ </li>
3121
+ ))
3122
+ : messages.map(renderMessageRow)}
3123
+ </ul>
3124
+ {hasMore && !rowCapReached && (
3125
+ <div ref={setSentinel} data-testid="load-more-sentinel" className="p-4 text-center text-xs text-text-muted">
3126
+ {loadMoreStatus}
3127
+ </div>
3128
+ )}
3129
+ {rowCapReached && (
3130
+ <p className="p-4 text-center text-xs text-text-muted">
3131
+ Showing the most recent {rowCap} messages &mdash; refine your search or filters to see more.
3132
+ </p>
3133
+ )}
3134
+ {aggregateFolderType && !isSearching && (
3135
+ <p className="p-4 text-center text-xs text-text-muted">
3136
+ Showing the most recent mail from each mailbox. Open a specific mailbox&rsquo;s folder to
3137
+ see older mail.
3138
+ </p>
3139
+ )}
3140
+ </>
3141
+ )}
3142
+ </div>
2964
3143
  </div>
2965
3144
  {/* The reading pane's own height: a row of the full-height mail view, stretched to it by the
2966
3145
  flex chain rather than by a percentage (an explicit height would opt it out of that