v0.2.14
RustBox CI / rustbox (push) Canceled after 0s

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-02 15:34:49 +01:00
1 parent 12e0c99850
commit edda5fc9e4
42 files changed
+733 -122

No files matched your search

+23 -7
View File
@@ -125,6 +125,19 @@ function estimateComposeMessageBytes(extraFiles = []) {
const mode = $("#compose-mode")?.value || "html";
if (mode === "html") bytes += utf8Bytes(editor.innerHTML);
else if (mode === "markdown") bytes += Math.ceil(plainBytes * 1.25);
const identity = typeof selectedIdentity === "function" ? selectedIdentity() : null;
const action = state.composeAction || "new";
const signatureEnabled = identity && (action === "reply"
? identity.signature_reply !== false
: action === "forward"
? identity.signature_forward !== false
: identity.signature_new !== false);
if (signatureEnabled && identity.signature_insert_mode !== "visible") {
const signatureText = identity.signature_text || "";
bytes += utf8Bytes(signatureText) + 8;
if (mode === "html") bytes += utf8Bytes(identity.signature_html || "") + 96;
}
}
for (const attachment of state.composeAttachments) bytes += estimatedMimeAttachmentBytes(attachment.size);
for (const file of extraFiles || []) bytes += estimatedMimeAttachmentBytes(file.size);
@@ -551,6 +564,7 @@ function composeDraftPayload() {
references: state.composeReplyMeta?.references || null,
request_mdn: Boolean($("#compose-mdn")?.checked),
priority: $("#compose-priority")?.value || "normal",
compose_action: state.composeAction || "new",
compose_format: $("#compose-mode")?.value || "html",
pgp_mode: $("#compose-pgp-mode")?.value || "none",
pgp_inline: Boolean($("#compose-pgp-inline")?.checked),
@@ -1414,8 +1428,7 @@ async function uploadInlineImage(files, insertionRange = null) {
async function openImapDraftComposer(folder, uid) {
const draft = await request(`/messages/${encodeURIComponent(folder)}/${uid}/draft-compose`, { method: "GET" });
openCompose("new");
state.composeSignatureGeneration += 1;
openCompose("new", { skipSignature: true });
state.composeDraftId = ensureDraftId();
state.composeRemoteDraft = draft.imap_source || { folder, uid, uid_validity: 0 };
state.composeAttachments = mergeComposeAttachments(draft.attachments);
@@ -1425,6 +1438,7 @@ async function openImapDraftComposer(folder, uid) {
inReplyTo: draft.in_reply_to || null,
references: draft.references || null,
};
state.composeAction = draft.in_reply_to ? "reply" : (/^fwd:/i.test(draft.subject || "") ? "forward" : "new");
$("#compose-to").value = draft.to || "";
$("#compose-cc").value = draft.cc || "";
$("#compose-bcc").value = draft.bcc || "";
@@ -1446,6 +1460,7 @@ async function openImapDraftComposer(folder, uid) {
const editor = $("#compose-editor");
if (mode === "html") editor.innerHTML = hydrateComposeHtml(draft.html_body || "", state.composeAttachments, state.composeDraftId);
else editor.textContent = draft.text_body || "";
insertIdentitySignature(editor, state.composeAction, { preserveExisting: true });
renderComposeAttachments();
state.composeDirty = false;
state.composeNeedsRemoteSync = false;
@@ -1458,7 +1473,6 @@ async function openImapDraftComposer(folder, uid) {
}
function applyRecoveredDraft(draft, sourceLabel = "Saved draft") {
state.composeSignatureGeneration += 1;
state.composeDraftId = draft.id || null;
state.composeRemoteDraft = draft.imap_source || null;
state.composeAttachments = mergeComposeAttachments(draft.attachments);
@@ -1468,6 +1482,7 @@ function applyRecoveredDraft(draft, sourceLabel = "Saved draft") {
inReplyTo: draft.in_reply_to || null,
references: draft.references || null,
};
state.composeAction = draft.compose_action || (draft.in_reply_to ? "reply" : (/^fwd:/i.test(draft.subject || "") ? "forward" : "new"));
$("#compose-to").value = draft.to || "";
$("#compose-cc").value = draft.cc || "";
$("#compose-bcc").value = draft.bcc || "";
@@ -1485,6 +1500,7 @@ function applyRecoveredDraft(draft, sourceLabel = "Saved draft") {
const editor = $("#compose-editor");
if (mode === "html" && draft.html_body) editor.innerHTML = hydrateComposeHtml(draft.html_body, state.composeAttachments, state.composeDraftId);
else editor.textContent = draft.text_body || "";
insertIdentitySignature(editor, state.composeAction, { preserveExisting: true });
renderComposeAttachments();
state.composeDirty = sourceLabel === "Browser recovery";
state.composeNeedsRemoteSync = sourceLabel === "Browser recovery";
@@ -1560,7 +1576,6 @@ async function closeComposer() {
if (!saved) toast("Draft kept in this browser for recovery", "warning", 5200);
}
if ($("#compose-dialog").open) $("#compose-dialog").close();
state.composeSignatureGeneration += 1;
}
function attachmentReminderNeeded() {
@@ -1649,7 +1664,7 @@ function toggleComposeFields() {
if (collapse) $("#compose-editor")?.focus();
}
function openCompose(mode = "new") {
function openCompose(mode = "new", options = {}) {
if (mode === "forward" && state.prefs.forwardMode === "attachment") {
void forwardAsAttachment();
return;
@@ -1662,13 +1677,13 @@ function openCompose(mode = "new") {
state.composeDraftId = null;
state.composeRemoteDraft = null;
state.composeAttachments = [];
state.composeSignatureGeneration += 1;
state.inlineAttachmentIds = new Set();
setSelectedInlineImage(null);
setComposeFieldsCollapsed(false);
state.composeDirty = false;
state.composeNeedsRemoteSync = false;
state.composeReplyMeta = null;
state.composeAction = mode === "reply" || mode === "reply-all" ? "reply" : mode === "forward" ? "forward" : "new";
setComposeUploadProgress(false);
renderComposeAttachments();
updateComposeDraftDeleteAction();
@@ -1728,7 +1743,7 @@ function openCompose(mode = "new") {
}
editor.append(quote);
}
insertIdentitySignature(editor, mode);
if (!options.skipSignature) insertIdentitySignature(editor, state.composeAction);
let fullScreen = $("#compose-dialog").classList.contains("compose-fullscreen");
try { fullScreen = localStorage.getItem("rustbox.composeFullscreen") === "1"; } catch (_) { }
setComposeFullscreen(fullScreen, false);
@@ -1791,6 +1806,7 @@ async function sendMessage(event) {
from_identity_id: $("#compose-from").value ? Number($("#compose-from").value) : null,
request_mdn: Boolean($("#compose-mdn").checked),
priority: $("#compose-priority").value || "normal",
compose_action: state.composeAction || "new",
pgp_mode: $("#compose-pgp-mode").value || "none",
pgp_inline: Boolean($("#compose-pgp-inline").checked),
pgp_passphrase: $("#compose-pgp-passphrase").value || "",