@bobfrankston/mailx 1.0.230 → 1.0.231

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.
@@ -211,9 +211,12 @@ export async function showMessage(accountId, uid, folderId, specialUse, isRetry
211
211
  });
212
212
  }
213
213
  headerEl.querySelector(".mv-date").textContent = new Date(msg.date).toLocaleString(undefined, { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: false });
214
- // Unsubscribe button (upper right of header)
214
+ // Unsubscribe button (upper right of header).
215
+ // - mailto: URLs open a pre-filled compose window (so the unsubscribe
216
+ // reply gets sent from the correct mailx account, not the OS default
217
+ // mail handler)
218
+ // - https: URLs open a new tab
215
219
  const unsubBtn = document.getElementById("mv-unsubscribe");
216
- // listUnsubscribe is now a clean URL (https:// or mailto:) from the server
217
220
  const unsubUrl = msg.listUnsubscribe || "";
218
221
  if (unsubBtn) {
219
222
  if (unsubUrl) {
@@ -223,7 +226,30 @@ export async function showMessage(accountId, uid, folderId, specialUse, isRetry
223
226
  unsubBtn.href = "#";
224
227
  unsubBtn.onclick = (e) => {
225
228
  e.preventDefault();
226
- window.open(unsubUrl, "_blank");
229
+ if (/^mailto:/i.test(unsubUrl)) {
230
+ // Parse mailto:addr?subject=... and pre-fill compose
231
+ const m = unsubUrl.match(/^mailto:([^?]*)(?:\?(.*))?$/i);
232
+ const to = m?.[1] ? decodeURIComponent(m[1]) : "";
233
+ const qs = new URLSearchParams(m?.[2] || "");
234
+ const subject = qs.get("subject") || "Unsubscribe";
235
+ const body = qs.get("body") || "";
236
+ const init = {
237
+ mode: "new",
238
+ accountId: currentAccountId,
239
+ to: to ? [{ name: "", address: to }] : [],
240
+ cc: [],
241
+ subject,
242
+ bodyHtml: body ? `<p>${body}</p>` : "",
243
+ inReplyTo: "",
244
+ references: [],
245
+ accounts: [],
246
+ };
247
+ sessionStorage.setItem("composeInit", JSON.stringify(init));
248
+ document.dispatchEvent(new CustomEvent("mailx-compose", { detail: { mode: "new" } }));
249
+ }
250
+ else {
251
+ window.open(unsubUrl, "_blank");
252
+ }
227
253
  };
228
254
  }
229
255
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.230",
3
+ "version": "1.0.231",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -24,7 +24,7 @@
24
24
  "@bobfrankston/iflow-node": "^0.1.2",
25
25
  "@bobfrankston/miscinfo": "^1.0.8",
26
26
  "@bobfrankston/oauthsupport": "^1.0.22",
27
- "@bobfrankston/msger": "^0.1.292",
27
+ "@bobfrankston/msger": "^0.1.293",
28
28
  "@capacitor/android": "^8.3.0",
29
29
  "@capacitor/cli": "^8.3.0",
30
30
  "@capacitor/core": "^8.3.0",
@@ -78,7 +78,7 @@
78
78
  "@bobfrankston/iflow-node": "^0.1.2",
79
79
  "@bobfrankston/miscinfo": "^1.0.8",
80
80
  "@bobfrankston/oauthsupport": "^1.0.22",
81
- "@bobfrankston/msger": "^0.1.292",
81
+ "@bobfrankston/msger": "^0.1.293",
82
82
  "@capacitor/android": "^8.3.0",
83
83
  "@capacitor/cli": "^8.3.0",
84
84
  "@capacitor/core": "^8.3.0",