@bobfrankston/rmfmail 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.js CHANGED
@@ -6,7 +6,7 @@ import { initFolderTree, refreshFolderTree, updateFolderCounts, setFolderSynced,
6
6
  import { initMessageList, loadMessages, loadUnifiedInbox, loadSearchResults, reloadCurrentFolder, clearSearchMode, getSelectedMessages, markBodiesCached, getCurrentFocused, releaseFocus, removeMessagesAndReconcile, setRowFlagged, scrollFocusedIntoView, refreshPriorityIndex } from "./components/message-list.js";
7
7
  import { seenOf, flaggedOf, draftOf, setSeen, setFlagged } from "@bobfrankston/mailx-types";
8
8
  import { getCurrentMessage, initViewer, popOutCurrentMessage, toggleFullscreenPreview, showPreviewBodyMenu, wrapHtmlBody } from "./components/message-viewer.js";
9
- import { connectWebSocket, onWsEvent, triggerSync, syncAccount, reauthenticate, getAccounts, getFolders, deleteMessages, undeleteMessage, restartServer, getSyncPending, getVersion, getSettings, saveSettings, getAutocompleteSettings, saveAutocompleteSettings, repairAccounts, updateFlags, markAsSpamMessages, logClientEvent, sendMessage as apiSendMessage } from "./lib/api-client.js";
9
+ import { connectWebSocket, onWsEvent, triggerSync, syncAccount, reauthenticate, getAccounts, getFolders, deleteMessages, undeleteMessage, restartServer, getSyncPending, getVersion, getSettings, saveSettings, getAutocompleteSettings, saveAutocompleteSettings, repairAccounts, updateFlags, markAsSpamMessages, logClientEvent, sendMessage as apiSendMessage, subscribeStore } from "./lib/api-client.js";
10
10
  import * as messageState from "./lib/message-state.js";
11
11
  // ── New message badge (favicon + title) ──
12
12
  /** The user-visible app name. Single point of change for the rename;
@@ -2480,25 +2480,7 @@ onWsEvent((event) => {
2480
2480
  // "not-downloaded" indicator to the teal dot for any rows in view.
2481
2481
  markBodiesCached(event.items || []);
2482
2482
  break;
2483
- case "bodyAvailable":
2484
- // Reconciler completed an interactive-lane fetch. The viewer
2485
- // listens for this directly to re-render the focused message;
2486
- // here we just clip the row's "not-downloaded" state so the
2487
- // dot updates immediately for the rest of the list.
2488
- if (event.accountId && event.uid) {
2489
- markBodiesCached([{ accountId: event.accountId, uid: event.uid }]);
2490
- }
2491
- break;
2492
- case "messageRemoved":
2493
- // Reconciler discovered a message gone from the server (another
2494
- // device deleted it, EXPUNGE landed). Local row is already gone;
2495
- // pull the row out of the rendered list if present.
2496
- if (event.accountId && event.uid) {
2497
- document.dispatchEvent(new CustomEvent("mailx-remove-stale", {
2498
- detail: { accountId: event.accountId, uid: event.uid },
2499
- }));
2500
- }
2501
- break;
2483
+ // bodyAvailable and messageRemoved migrated to subscribeStore below.
2502
2484
  case "syncStateChanged": {
2503
2485
  // Drives the bottom-right sync-status pill. Same surface used by
2504
2486
  // syncProgress / folderSynced; reconciler ticks this every few
@@ -2719,6 +2701,24 @@ onWsEvent((event) => {
2719
2701
  }
2720
2702
  }
2721
2703
  });
2704
+ // Store-bus consumers (post-refactor). bodyAvailable / messageRemoved
2705
+ // previously fanned out via the legacy onEvent({type:...}) channel; the
2706
+ // reconciler now publishes directly on storeBus and the wildcard catches
2707
+ // both folder:<id> and message:<uuid> topic forms.
2708
+ subscribeStore("*", (ev) => {
2709
+ if (ev.kind === "bodyAvailable" && ev.accountId && ev.uid) {
2710
+ // Flip the row's "not-downloaded" dot. Viewer subscribes separately
2711
+ // (in message-viewer.ts) to re-render the focused message.
2712
+ markBodiesCached([{ accountId: ev.accountId, uid: ev.uid }]);
2713
+ }
2714
+ else if (ev.kind === "messageRemoved" && ev.accountId && ev.uid) {
2715
+ // Server-side EXPUNGE (or another device deleted) — yank the row
2716
+ // out of the list if it's still rendered.
2717
+ document.dispatchEvent(new CustomEvent("mailx-remove-stale", {
2718
+ detail: { accountId: ev.accountId, uid: ev.uid },
2719
+ }));
2720
+ }
2721
+ });
2722
2722
  /** Open a compose window pre-filled from a mailto: URL. Same plumbing as
2723
2723
  * openCompose("new") but the init shape comes from the parsed URL instead
2724
2724
  * of the currently-selected message. The body arrives as plain text from