@bobfrankston/rmfmail 1.1.181 → 1.1.182

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,42 @@ 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
+ if (visible > 0) {
3407
+ EXISTING?.remove();
3408
+ return;
3409
+ }
3410
+ if (EXISTING)
3411
+ return;
3412
+ const which = flaggedOnly && priorityOnly ? "flagged + priority" : flaggedOnly ? "flagged" : "priority";
3413
+ const overlay = document.createElement("div");
3414
+ overlay.className = "ml-empty ml-filter-empty";
3415
+ 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>`;
3416
+ body.appendChild(overlay);
3417
+ overlay.querySelector(".ml-filter-clear")?.addEventListener("click", () => {
3418
+ document.dispatchEvent(new CustomEvent("mailx-clear-list-filters"));
3419
+ });
3420
+ }
3421
+ function escapeHtmlText(s) {
3422
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3423
+ }
3388
3424
  function appendMessages(body, accountId, items) {
3389
3425
  const threaded = body.classList.contains("threaded");
3390
3426
  let rowsToRender = items;
@@ -10261,6 +10297,15 @@ if (optPriorityOnly) {
10261
10297
  localStorage.setItem("mailx-priority-only", String(optPriorityOnly.checked));
10262
10298
  });
10263
10299
  }
10300
+ document.addEventListener("mailx-clear-list-filters", () => {
10301
+ applyFlaggedFilter(false);
10302
+ if (optPriorityOnly?.checked) {
10303
+ optPriorityOnly.checked = false;
10304
+ document.getElementById("ml-body")?.classList.remove("priority-only");
10305
+ localStorage.setItem("mailx-priority-only", "false");
10306
+ }
10307
+ reloadCurrentFolder();
10308
+ });
10264
10309
  optFolderCounts?.addEventListener("change", () => {
10265
10310
  const tree = document.getElementById("folder-tree");
10266
10311
  if (optFolderCounts.checked) {