domma-cms 1.34.0 → 1.35.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 (81) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/package.json +1 -1
  3. package/plugins/_lib/admin/mail/body-menu.js +1 -1
  4. package/plugins/_lib/admin/mail/cms-host.js +1 -1
  5. package/plugins/_lib/admin/mail/compose-window.js +1 -1
  6. package/plugins/_lib/admin/mail/contacts.js +1 -1
  7. package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
  8. package/plugins/_lib/admin/mail/drag-drop.js +1 -1
  9. package/plugins/_lib/admin/mail/folder-tree.js +26 -1
  10. package/plugins/_lib/admin/mail/font-controls.js +1 -1
  11. package/plugins/_lib/admin/mail/fonts.js +1 -1
  12. package/plugins/_lib/admin/mail/host-context.js +1 -1
  13. package/plugins/_lib/admin/mail/identity.js +1 -1
  14. package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
  15. package/plugins/_lib/admin/mail/keyboard.js +1 -1
  16. package/plugins/_lib/admin/mail/mail.html +4 -1
  17. package/plugins/_lib/admin/mail/message-actions.js +1 -1
  18. package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
  19. package/plugins/_lib/admin/mail/panes.js +1 -1
  20. package/plugins/_lib/admin/mail/reader-kit.js +9 -3
  21. package/plugins/_lib/admin/mail/reader-runtime.js +154 -6
  22. package/plugins/_lib/admin/mail/reader-view.js +1 -1
  23. package/plugins/_lib/admin/mail/resizable.js +1 -1
  24. package/plugins/_lib/admin/mail/restore-spam.js +1 -1
  25. package/plugins/_lib/admin/mail/rules.js +1 -1
  26. package/plugins/_lib/admin/mail/scheduling.js +1 -1
  27. package/plugins/_lib/admin/mail/section-kit.js +1 -1
  28. package/plugins/_lib/admin/mail/security-note.js +1 -1
  29. package/plugins/_lib/admin/mail/settings-section.js +1 -1
  30. package/plugins/_lib/admin/mail/templates.js +1 -1
  31. package/plugins/_lib/admin/mail/threads.js +1 -1
  32. package/plugins/_lib/admin/mail/vacation.js +1 -1
  33. package/plugins/_lib/admin/mail/when-closed.js +1 -1
  34. package/plugins/_lib/admin/ui/dates.js +1 -1
  35. package/plugins/_lib/admin/ui/resizable.js +1 -1
  36. package/plugins/_lib/domma-mail.lock.json +80 -80
  37. package/plugins/_lib/mail/accountFileStore.js +1 -1
  38. package/plugins/_lib/mail/accountRepository.js +1 -1
  39. package/plugins/_lib/mail/accountRoutes.js +1 -1
  40. package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
  41. package/plugins/_lib/mail/bodyTokens.js +1 -1
  42. package/plugins/_lib/mail/compose.js +1 -1
  43. package/plugins/_lib/mail/defaults.js +1 -1
  44. package/plugins/_lib/mail/envelope.js +1 -1
  45. package/plugins/_lib/mail/folderActions.js +1 -1
  46. package/plugins/_lib/mail/folderRuntime.js +1 -1
  47. package/plugins/_lib/mail/folders.js +1 -1
  48. package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
  49. package/plugins/_lib/mail/mbox.js +1 -1
  50. package/plugins/_lib/mail/message-action.js +1 -1
  51. package/plugins/_lib/mail/messageSecurity.js +1 -1
  52. package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
  53. package/plugins/_lib/mail/networkAddresses.js +1 -1
  54. package/plugins/_lib/mail/networkPolicy.js +1 -1
  55. package/plugins/_lib/mail/oauthAccounts.js +1 -1
  56. package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
  57. package/plugins/_lib/mail/oauthRuntime.js +1 -1
  58. package/plugins/_lib/mail/pollSchedule.js +1 -1
  59. package/plugins/_lib/mail/poller.js +1 -1
  60. package/plugins/_lib/mail/pollerRuntime.js +1 -1
  61. package/plugins/_lib/mail/priority.js +1 -1
  62. package/plugins/_lib/mail/publicMailbox.js +1 -1
  63. package/plugins/_lib/mail/readRuntime.js +1 -1
  64. package/plugins/_lib/mail/render.js +1 -1
  65. package/plugins/_lib/mail/ruleRunner.js +1 -1
  66. package/plugins/_lib/mail/schedulerRuntime.js +1 -1
  67. package/plugins/_lib/mail/secretProvider.js +1 -1
  68. package/plugins/_lib/mail/secretbox.js +1 -1
  69. package/plugins/_lib/mail/senderAuth.js +1 -1
  70. package/plugins/_lib/mail/sieve.js +1 -1
  71. package/plugins/_lib/mail/smtpService.js +1 -1
  72. package/plugins/_lib/mail/snoozeRuntime.js +1 -1
  73. package/plugins/_lib/mail/store.js +1 -1
  74. package/plugins/_lib/mail/subscriptions.js +1 -1
  75. package/plugins/_lib/mail/syncPlan.js +1 -1
  76. package/plugins/_lib/mail/syncRuntime.js +1 -1
  77. package/plugins/_lib/mail/syncSelection.js +1 -1
  78. package/plugins/_lib/mail/unreadBadge.js +1 -1
  79. package/plugins/_lib/mail/unsubscribe.js +1 -1
  80. package/plugins/_lib/mail/vacationRuntime.js +1 -1
  81. package/plugins/_lib/mail/write.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.35.0] - 2026-11-03
4
+
5
+ - **Open or close every mail folder at once.** Email and Mail Reader offer Open all folders and Close all folders on a mailbox's right-click menu, on the Folders heading's right-click menu, and as a button in the Folders heading (which switches between the two, and is the place to find it with a single mailbox).
6
+ - **Mark a folder and the folders inside it.** In Email, Mark all as read and Mark all as unread on a folder that holds other folders open a submenu: This folder, or Including folders inside. Each folder is done in turn and one message reports the total.
7
+
3
8
  ## [1.34.0] - 2026-11-03
4
9
 
5
10
  - Email Pro can notify for all folders or selected folders, with Check all and None controls in Email Settings. Folder choices are saved per mailbox and automatically included in background syncing. The sidebar badge continues to count Inbox unread messages. Folder notification marks are independent, including mailboxes with more than fifty folders.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domma-cms",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "description": "File-based CMS powered by Domma and Fastify. Run npx domma-cms my-site to create a new project.",
5
5
  "type": "module",
6
6
  "main": "server/server.js",
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/body-menu.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/body-menu.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reading pane's right-click menu - the pure parts.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/cms-host.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/cms-host.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** The CMS shell boundary. Standalone never imports this adapter. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/compose-window.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/compose-window.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/contacts.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/contacts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Recipient suggestions from the host address book.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/diagnostics-section.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/diagnostics-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section that answers "which build is this, and what went wrong".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/drag-drop.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/drag-drop.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Drag identities include the mailbox and source folder: UIDs alone are not unique. */
4
4
  const PROTECTED_USES = new Set(['\\Inbox', '\\Sent', '\\Drafts', '\\Trash', '\\Junk', '\\Archive', '\\All', '\\Flagged']);
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/folder-tree.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/folder-tree.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Mail folder presentation, shared by the Mail Reader and Email Pro.
@@ -174,6 +174,31 @@ export function unreadInSubtree(node) {
174
174
  return node.children.reduce((total, child) => total + unreadInSubtree(child), own);
175
175
  }
176
176
 
177
+ /**
178
+ * Every folder that has folders inside it - what "Close all folders" shuts.
179
+ *
180
+ * @param {object[]} roots
181
+ * @returns {string[]}
182
+ */
183
+ export function foldablePaths(roots) {
184
+ return flattenFolderTree(roots).filter(node => node.children.length > 0).map(node => node.path);
185
+ }
186
+
187
+ /**
188
+ * A folder and every folder beneath it that can hold mail, parent first -
189
+ * what "including folders inside" acts on. Unselectable levels (a parent a
190
+ * server lists only as a container, or one the tree synthesised) are left out.
191
+ *
192
+ * @param {object[]} roots
193
+ * @param {string} path
194
+ * @returns {string[]} empty when the path is not in the tree
195
+ */
196
+ export function subtreePaths(roots, path) {
197
+ const node = flattenFolderTree(roots).find(item => item.path === path);
198
+ if (!node) return [];
199
+ return flattenFolderTree([node]).filter(item => item.selectable !== false).map(item => item.path);
200
+ }
201
+
177
202
  /**
178
203
  * Keep only the branches that lead to unread mail.
179
204
  *
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/font-controls.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/font-controls.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/fonts.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/fonts.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The fonts and sizes the mail editor offers - pure, so both the compose
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/host-context.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/host-context.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Services supplied by the application that hosts the shared mail interface. */
4
4
  export function createMailApi({getToken, fetch: request = globalThis.fetch, onUnauthorized = () => {}}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/identity.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/identity.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Who a mailbox sends as, and what it signs off with.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/image-senders-section.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/image-senders-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The settings section for senders whose images always load.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/keyboard.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/keyboard.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Keyboard navigation for the reader.
@@ -1,4 +1,4 @@
1
- <!-- Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/mail.html. -->
1
+ <!-- Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/mail.html. -->
2
2
  <div class="mail-layout">
3
3
 
4
4
  <!-- Folders -->
@@ -9,6 +9,9 @@
9
9
  <input type="checkbox" id="mail-unread-only">
10
10
  <span>Unread</span>
11
11
  </label>
12
+ <button class="btn btn-sm btn-ghost" id="mail-fold-all-btn" title="Close all folders" hidden>
13
+ <span data-icon="chevrons-right" data-icon-size="14"></span>
14
+ </button>
12
15
  <button class="btn btn-sm btn-ghost" id="mail-new-folder-btn" title="New folder" hidden>
13
16
  <span data-icon="folder-plus" data-icon-size="14"></span>
14
17
  </button>
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/message-actions.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/message-actions.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * What other Tools add to a message's menu - Booking's "Book Sam...".
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/oauth-panel.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/oauth-panel.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * "Sign in with Microsoft / Google" for a mailbox - the part of the mailbox
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/panes.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/panes.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Pane sizing for the mail reader, shared by the Mail Reader and Email Pro.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/reader-kit.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/reader-kit.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The reader view's decisions that need no DOM - escaping, the mailbox form's
@@ -237,14 +237,20 @@ export function onceOnly() {
237
237
  /**
238
238
  * What a mailbox row's menu offers, as ids the view maps to actions.
239
239
  *
240
- * @param {{isCurrent: boolean, isDefault: boolean, count: number, canWrite?: boolean}} o
240
+ * @param {{isCurrent: boolean, isDefault: boolean, count: number, foldable?: number|null}} o
241
241
  * @returns {{id: string, label: string, icon: string, disabled?: boolean, danger?: boolean}[]|object[]}
242
242
  */
243
- export function accountMenuModel({isCurrent = false, isDefault = false, count = 1} = {}) {
243
+ export function accountMenuModel({isCurrent = false, isDefault = false, count = 1, foldable = null} = {}) {
244
+ // `foldable` is how many folders have folders inside, known only for the
245
+ // open mailbox; for another one the items open it first, so they stay on.
246
+ const nothingToFold = isCurrent && foldable === 0;
244
247
  return [
245
248
  {id: 'open', label: isCurrent ? 'Open (already open)' : 'Open', icon: 'inbox', disabled: isCurrent},
246
249
  {id: 'refresh', label: 'Check for new mail', icon: 'refresh-cw', disabled: !isCurrent},
247
250
  {type: 'divider'},
251
+ {id: 'expandAll', label: 'Open all folders', icon: 'chevrons-down', disabled: nothingToFold},
252
+ {id: 'collapseAll', label: 'Close all folders', icon: 'chevrons-right', disabled: nothingToFold},
253
+ {type: 'divider'},
248
254
  {id: 'edit', label: 'Edit…', icon: 'edit-3'},
249
255
  ...(count > 1 ? [{id: 'default', label: isDefault ? 'Unset default' : 'Make default', icon: 'star'}] : []),
250
256
  {type: 'divider'},
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/reader-runtime.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/reader-runtime.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  const {createMailHost} = await import(new URL(`./host-context.js?v=${MAIL_MODULE_VERSION}`, import.meta.url).href);
@@ -35,9 +35,11 @@ const {
35
35
  flattenFolderTree,
36
36
  folderHeading,
37
37
  folderMenuItems,
38
+ foldablePaths,
38
39
  iconForFolder,
39
40
  isSpamFolder,
40
41
  pruneToUnread,
42
+ subtreePaths,
41
43
  unreadInSubtree
42
44
  } = await import(versioned('folder-tree.js'));
43
45
  const {imageSendersSection} = await import(versioned('image-senders-section.js'));
@@ -296,6 +298,7 @@ return {
296
298
  */
297
299
  let folderMenu = null;
298
300
  let folderActionMenu = null;
301
+ let folderHeadMenu = null;
299
302
  let folderActionBusy = false;
300
303
  let dragState = null;
301
304
  let dropBusy = false;
@@ -384,6 +387,27 @@ return {
384
387
  renderFolders();
385
388
  }
386
389
 
390
+ /**
391
+ * Open or shut every folder in a mailbox, opening that mailbox first
392
+ * when it is not the one on screen (only its folders are loaded).
393
+ *
394
+ * @param {string} accountId
395
+ * @param {boolean} open
396
+ * @returns {Promise<void>}
397
+ */
398
+ async function setAllFolded(accountId, open) {
399
+ if (accountId !== currentAccountId) await selectAccount(accountId);
400
+ if (!here() || currentAccountId !== accountId) return;
401
+ const paths = open ? [] : foldablePaths(buildFolderTree(folders));
402
+ collapsedByAccount = {...collapsedByAccount, [currentAccountId]: paths};
403
+ try {
404
+ S.set(COLLAPSED_KEY, collapsedByAccount);
405
+ } catch {
406
+ // Storage unavailable - the fold still works for this visit.
407
+ }
408
+ renderFolders();
409
+ }
410
+
387
411
  const foldersEl = $container.find('#mail-folders-list').get(0);
388
412
  const listEl = $container.find('#mail-list').get(0);
389
413
  const selectAllEl = $container.find('#mail-select-all').get(0);
@@ -393,6 +417,7 @@ return {
393
417
  const readerBodyEl = $container.find('#mail-reader-body').get(0);
394
418
  const listTitleEl = $container.find('#mail-list-title').get(0);
395
419
  const folderActionsBtn = $container.find('#mail-folder-actions-btn').get(0);
420
+ const foldAllBtn = $container.find('#mail-fold-all-btn').get(0);
396
421
  const searchEl = $container.find('#mail-search').get(0);
397
422
  const searchInputEl = $container.find('#mail-search-input').get(0);
398
423
  const searchClearEl = $container.find('#mail-search-clear').get(0);
@@ -691,6 +716,8 @@ return {
691
716
  folderMenu = null;
692
717
  folderActionMenu?.destroy?.();
693
718
  folderActionMenu = null;
719
+ folderHeadMenu?.destroy?.();
720
+ folderHeadMenu = null;
694
721
  clearDrag();
695
722
  stopFitting?.();
696
723
  stopFitting = null;
@@ -1910,6 +1937,7 @@ return {
1910
1937
  foldersEl.textContent = '';
1911
1938
  if (folderActionsBtn) folderActionsBtn.disabled = !currentAccountId || folderActionBusy || !folders.length;
1912
1939
  paintUnreadFilter();
1940
+ paintFoldAll();
1913
1941
 
1914
1942
  for (const box of mailboxes) {
1915
1943
  const isCurrent = box.id === currentAccountId;
@@ -2073,6 +2101,37 @@ return {
2073
2101
  *
2074
2102
  * @returns {void}
2075
2103
  */
2104
+ /**
2105
+ * What the Folders head offers for the open mailbox: open everything
2106
+ * when every branch is shut, otherwise close everything. Nothing to
2107
+ * fold, no button.
2108
+ *
2109
+ * @returns {{foldable: string[], allShut: boolean}}
2110
+ */
2111
+ function foldAllState() {
2112
+ const foldable = currentAccountId ? foldablePaths(buildFolderTree(folders)) : [];
2113
+ const collapsed = collapsedSet();
2114
+ return {foldable, allShut: foldable.length > 0 && foldable.every(path => collapsed.has(path))};
2115
+ }
2116
+
2117
+ /** @returns {void} */
2118
+ function paintFoldAll() {
2119
+ if (!foldAllBtn) return;
2120
+ const {foldable, allShut} = foldAllState();
2121
+ foldAllBtn.hidden = !foldable.length;
2122
+ const label = allShut ? 'Open all folders' : 'Close all folders';
2123
+ foldAllBtn.title = label;
2124
+ foldAllBtn.setAttribute('aria-label', label);
2125
+ const icon = allShut ? 'chevrons-down' : 'chevrons-right';
2126
+ if (foldAllBtn.dataset.icon === icon) return;
2127
+ foldAllBtn.dataset.icon = icon;
2128
+ const glyph = document.createElement('span');
2129
+ glyph.setAttribute('data-icon', icon);
2130
+ glyph.setAttribute('data-icon-size', '14');
2131
+ foldAllBtn.replaceChildren(glyph);
2132
+ try { Domma.icons?.scan?.(foldAllBtn); } catch { /* the title still names it */ }
2133
+ }
2134
+
2076
2135
  function paintUnreadFilter() {
2077
2136
  const label = unreadFilterEl?.querySelector('span');
2078
2137
  if (!label) return;
@@ -5214,6 +5273,24 @@ return {
5214
5273
  return true;
5215
5274
  }
5216
5275
  });
5276
+ // The Folders head: open or close every folder - the only place
5277
+ // for it when there is one mailbox and so no mailbox row.
5278
+ const head = foldersEl.closest('.mail-folders-pane')?.querySelector('.mail-pane-head');
5279
+ if (head) {
5280
+ folderHeadMenu = elements.contextMenu(head, {
5281
+ inherit: false,
5282
+ items: [],
5283
+ onBeforeOpen: () => {
5284
+ const {foldable} = foldAllState();
5285
+ if (!foldable.length) return false;
5286
+ folderHeadMenu.setItems([
5287
+ {label: 'Open all folders', icon: 'chevrons-down', action: () => setAllFolded(currentAccountId, true)},
5288
+ {label: 'Close all folders', icon: 'chevrons-right', action: () => setAllFolded(currentAccountId, false)}
5289
+ ]);
5290
+ return true;
5291
+ }
5292
+ });
5293
+ }
5217
5294
  if (features.folders && folderActionsBtn) {
5218
5295
  folderActionsBtn.hidden = false;
5219
5296
  folderActionMenu = elements.contextMenu(folderActionsBtn, {
@@ -5240,10 +5317,13 @@ return {
5240
5317
  return mergeExtensionItems(menuItems(accountMenuModel({
5241
5318
  isCurrent: box.id === currentAccountId,
5242
5319
  isDefault: box.isDefault === true,
5243
- count: mailboxes.length
5320
+ count: mailboxes.length,
5321
+ foldable: box.id === currentAccountId ? foldablePaths(buildFolderTree(folders)).length : null
5244
5322
  }), {
5245
5323
  open: () => selectAccount(box.id),
5246
5324
  refresh: () => refreshMailbox(),
5325
+ expandAll: () => setAllFolded(box.id, true),
5326
+ collapseAll: () => setAllFolded(box.id, false),
5247
5327
  edit: () => openMailboxForm(box),
5248
5328
  default: () => toggleDefaultMailbox(box),
5249
5329
  remove: () => removeMailbox(box)
@@ -5290,14 +5370,23 @@ return {
5290
5370
  const read = folderReadItems(folder);
5291
5371
  const extra = extensionItems('folderItems', folder);
5292
5372
  if (!features.folders) return mergeExtensionItems(read, extra);
5373
+ // A folder with folders inside offers "this one" or "the lot" as a
5374
+ // submenu; a leaf keeps the plain item.
5375
+ const inside = subtreePaths(buildFolderTree(folders), folder.path).filter(path => path !== folder.path);
5376
+ const markItem = (label, icon, action) => !inside.length
5377
+ ? {label, icon, disabled: () => folderActionBusy, action: () => folderContentsAction(folder, action)}
5378
+ : {label, icon, disabled: () => folderActionBusy, submenu: [
5379
+ {label: 'This folder', icon: 'folder', disabled: () => folderActionBusy || folder.selectable === false,
5380
+ action: () => folderContentsAction(folder, action)},
5381
+ {label: 'Including folders inside', icon: 'folder-open', disabled: () => folderActionBusy,
5382
+ action: () => folderTreeAction(folder, action)}
5383
+ ]};
5293
5384
  return mergeExtensionItems([
5294
5385
  ...read,
5295
5386
  {type: 'divider'},
5296
5387
  {label: 'Refresh folders', icon: 'refresh-cw', action: () => refreshFolders()},
5297
- {label: 'Mark all as read', icon: 'mail-open', disabled: () => folderActionBusy,
5298
- action: () => folderContentsAction(folder, 'markRead')},
5299
- {label: 'Mark all as unread', icon: 'mail', disabled: () => folderActionBusy,
5300
- action: () => folderContentsAction(folder, 'markUnread')},
5388
+ markItem('Mark all as read', 'mail-open', 'markRead'),
5389
+ markItem('Mark all as unread', 'mail', 'markUnread'),
5301
5390
  {label: folder.specialUse === '\\Trash' ? 'Empty Trash...' : 'Clear folder...', icon: 'trash', danger: true,
5302
5391
  disabled: () => folderActionBusy || ['\\All', '\\Flagged'].includes(folder.specialUse)
5303
5392
  || !folders.some(item => item.specialUse === '\\Trash'),
@@ -5353,6 +5442,62 @@ return {
5353
5442
  ], extra);
5354
5443
  }
5355
5444
 
5445
+ /**
5446
+ * Mark every message in a folder and the folders beneath it, one
5447
+ * folder at a time (the server allows one folder action per mailbox).
5448
+ *
5449
+ * @param {object} folder
5450
+ * @param {'markRead'|'markUnread'} action
5451
+ * @returns {Promise<void>}
5452
+ */
5453
+ async function folderTreeAction(folder, action) {
5454
+ if (folderActionBusy || !currentAccountId) return;
5455
+ const account = currentAccountId;
5456
+ const paths = subtreePaths(buildFolderTree(folders), folder.path);
5457
+ if (!paths.length) return;
5458
+ folderActionBusy = true;
5459
+ if (folderActionsBtn) folderActionsBtn.disabled = true;
5460
+ let count = 0;
5461
+ let done = 0;
5462
+ const failed = [];
5463
+ try {
5464
+ if (paths.includes(currentFolder)) cancelMarkRead();
5465
+ for (const path of paths) {
5466
+ if (!here() || currentAccountId !== account) return;
5467
+ try {
5468
+ const result = await api(`${BASE}/folders/messages?${new URLSearchParams({account})}`, 'POST', {
5469
+ path, action, confirmed: false
5470
+ });
5471
+ count += Number(result?.processed) || 0;
5472
+ done++;
5473
+ } catch {
5474
+ failed.push(path);
5475
+ }
5476
+ }
5477
+ if (!here() || currentAccountId !== account) return;
5478
+ const word = action === 'markRead' ? 'read' : 'unread';
5479
+ const where = `${done} folder${done === 1 ? '' : 's'}`;
5480
+ if (failed.length) {
5481
+ E.toast(`Marked ${count} messages as ${word} in ${where}; could not do ${failed.join(', ')}.`, {type: 'warning'});
5482
+ } else {
5483
+ E.toast(`Marked ${count} messages as ${word} in ${where}.`, {type: 'success'});
5484
+ }
5485
+ } finally {
5486
+ folderActionBusy = false;
5487
+ if (here()) {
5488
+ if (folderActionsBtn) folderActionsBtn.disabled = !currentAccountId || !folders.length;
5489
+ if (currentAccountId === account) {
5490
+ if (paths.includes(currentFolder)) {
5491
+ clearSelection();
5492
+ page = 1;
5493
+ }
5494
+ await refreshFolders();
5495
+ if (searchQuery) await loadMessages({fresh: true, quiet: true});
5496
+ }
5497
+ }
5498
+ }
5499
+ }
5500
+
5356
5501
  /** Apply to the entire named folder, including messages beyond this page. */
5357
5502
  async function folderContentsAction(folder, action) {
5358
5503
  if (folderActionBusy || !currentAccountId) return;
@@ -6425,6 +6570,9 @@ return {
6425
6570
  } catch { /* no banner: the pane buttons stay */ }
6426
6571
  if (!here()) return;
6427
6572
  $container.find('#mail-refresh-btn').on('click', () => refreshMailbox());
6573
+ foldAllBtn?.addEventListener('click', () => {
6574
+ if (currentAccountId) setAllFolded(currentAccountId, foldAllState().allShut);
6575
+ });
6428
6576
 
6429
6577
  // Folder management was right-click only, which is the same as not
6430
6578
  // existing for anyone who does not already know it is there.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/reader-view.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/reader-view.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Existing CMS entry point for the shared mail view. */
4
4
  const version = new URL(import.meta.url).searchParams.get('v') ?? '1';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/resizable.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/resizable.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The mail reader's resizable slideovers.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/restore-spam.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/restore-spam.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Undo restores both junk status and the original folder, following each UID remap. */
4
4
  export async function restoreSpam({api, base, account, from, destination, uids, spam}) {
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/rules.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/rules.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Filing rules.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/scheduling.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/scheduling.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/section-kit.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/section-kit.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/security-note.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/security-note.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * What the reader says about a signed or encrypted (S/MIME) message.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/settings-section.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/settings-section.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /** Browser preferences for the shared mail reader. */
4
4
  export const READ_DELAY_KEY = 'domma-mail.mark-read-seconds';
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/templates.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/templates.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  const MAIL_MODULE_VERSION = new URL(import.meta.url).searchParams.get('v') ?? '1';
4
4
  /**
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/threads.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/threads.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Grouping messages into conversations.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/vacation.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/vacation.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * The automatic reply, and everything that must stop it.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/mail/when-closed.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/mail/when-closed.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Run code when a Domma modal or slideover actually closes.
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/ui/dates.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/ui/dates.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Dates as a plugin shows them to a person: dd/mm/yyyy, and dd/mm/yyyy HH:mm
@@ -1,4 +1,4 @@
1
- // Source: @domma-mail/core 0.21.0, packages/core/src/admin/ui/resizable.js.
1
+ // Source: @domma-mail/core 0.22.0, packages/core/src/admin/ui/resizable.js.
2
2
  // Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
3
3
  /**
4
4
  * Making a slideover resizable.