@bobfrankston/rmfmail 1.1.181 → 1.1.183

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.
@@ -3289,7 +3289,7 @@ function renderMessages(body, accountId, items) {
3289
3289
  fragment.appendChild(tempDiv.firstChild);
3290
3290
  body.replaceChildren(fragment);
3291
3291
  try {
3292
- logClientEvent("renderMessages", { items: items.length, domRows: body.querySelectorAll(".ml-row").length, bodyClass: body.className, bodyChildren: body.childElementCount });
3292
+ maybeShowFilterEmptyState(body);
3293
3293
  } catch {
3294
3294
  }
3295
3295
  if (focusedRow) {
@@ -3385,6 +3385,46 @@ async function showThreadPopup(pillEl, headMsg) {
3385
3385
  document.addEventListener("mousedown", dismiss, true);
3386
3386
  }, 0);
3387
3387
  }
3388
+ function maybeShowFilterEmptyState(body) {
3389
+ const EXISTING = body.querySelector(":scope > .ml-filter-empty");
3390
+ const rows = body.querySelectorAll(".ml-row");
3391
+ const flaggedOnly = body.classList.contains("flagged-only");
3392
+ const priorityOnly = body.classList.contains("priority-only");
3393
+ if (!flaggedOnly && !priorityOnly || rows.length === 0) {
3394
+ EXISTING?.remove();
3395
+ return;
3396
+ }
3397
+ let visible = 0;
3398
+ for (const r of rows) {
3399
+ const el = r;
3400
+ if (flaggedOnly && !el.classList.contains("flagged"))
3401
+ continue;
3402
+ if (priorityOnly && !el.classList.contains("priority"))
3403
+ continue;
3404
+ visible++;
3405
+ }
3406
+ try {
3407
+ logClientEvent("filterEmptyState", { flaggedOnly, priorityOnly, domRows: rows.length, visible, alreadyShown: !!EXISTING });
3408
+ } catch {
3409
+ }
3410
+ if (visible > 0) {
3411
+ EXISTING?.remove();
3412
+ return;
3413
+ }
3414
+ if (EXISTING)
3415
+ return;
3416
+ const which = flaggedOnly && priorityOnly ? "flagged + priority" : flaggedOnly ? "flagged" : "priority";
3417
+ const overlay = document.createElement("div");
3418
+ overlay.className = "ml-empty ml-filter-empty";
3419
+ overlay.innerHTML = `<div style="text-align:center;padding:24px 16px;"><div style="font-weight:600;margin-bottom:6px;">No ${escapeHtmlText(which)} messages</div><div style="opacity:0.75;margin-bottom:12px;">A "${escapeHtmlText(which)} only" filter is hiding ${rows.length} message${rows.length === 1 ? "" : "s"}.</div><button type="button" class="ml-filter-clear" style="padding:6px 14px;cursor:pointer;">Show all messages</button></div>`;
3420
+ body.appendChild(overlay);
3421
+ overlay.querySelector(".ml-filter-clear")?.addEventListener("click", () => {
3422
+ document.dispatchEvent(new CustomEvent("mailx-clear-list-filters"));
3423
+ });
3424
+ }
3425
+ function escapeHtmlText(s) {
3426
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3427
+ }
3388
3428
  function appendMessages(body, accountId, items) {
3389
3429
  const threaded = body.classList.contains("threaded");
3390
3430
  let rowsToRender = items;
@@ -10261,6 +10301,15 @@ if (optPriorityOnly) {
10261
10301
  localStorage.setItem("mailx-priority-only", String(optPriorityOnly.checked));
10262
10302
  });
10263
10303
  }
10304
+ document.addEventListener("mailx-clear-list-filters", () => {
10305
+ applyFlaggedFilter(false);
10306
+ if (optPriorityOnly?.checked) {
10307
+ optPriorityOnly.checked = false;
10308
+ document.getElementById("ml-body")?.classList.remove("priority-only");
10309
+ localStorage.setItem("mailx-priority-only", "false");
10310
+ }
10311
+ reloadCurrentFolder();
10312
+ });
10264
10313
  optFolderCounts?.addEventListener("change", () => {
10265
10314
  const tree = document.getElementById("folder-tree");
10266
10315
  if (optFolderCounts.checked) {