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

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-04 14:59:03 +01:00
1 parent 6e74b33f03
commit 3b9110c8c8
44 files changed
+3057 -128

No files matched your search

+32 -2
View File
@@ -1788,6 +1788,32 @@ function buildReferences(detail) {
return values.length ? values.join(" ") : null;
}
// "Undo Send": the server held the just-sent message back for a few seconds
// instead of dispatching it immediately. Show a toast with an Undo action
// for the whole window, then poll once for the final result so a send that
// actually failed in the background is still reported.
function notifyUndoSendStaged(pendingId, windowSecs) {
const seconds = Math.max(0, windowSecs);
toast("Sending\u2026", "info", seconds * 1000 || 4000, {
label: "Undo",
onClick: async () => {
try {
await request(`/messages/send/${encodeURIComponent(pendingId)}`, { method: "DELETE" });
toast("Send cancelled", "success");
} catch (error) {
toast(error?.message || "Too late to cancel", "warning");
}
},
});
setTimeout(async () => {
try {
const final = await request(`/messages/send/${encodeURIComponent(pendingId)}`);
if (final?.status === "sent") toast("Message sent", "success");
else if (final?.status === "failed") toast(`Could not send: ${final.error || "unknown error"}`, "error");
} catch (_) { /* already swept or still dispatching; nothing useful to report */ }
}, seconds * 1000 + 1500);
}
async function sendMessage(event) {
event.preventDefault();
if (state.composeUploading) return toast("Wait for the attachment upload to finish", "warning");
@@ -1821,7 +1847,7 @@ async function sendMessage(event) {
setBusy(send, true);
const editor = $("#compose-editor");
try {
await request("/messages/send", {
const sendResult = await request("/messages/send", {
method: "POST",
body: JSON.stringify({
to: parseRecipients($("#compose-to").value),
@@ -1865,7 +1891,11 @@ async function sendMessage(event) {
state.pgpRecipientStatus = [];
$("#compose-pgp-passphrase").value = "";
updateComposeMessageSize();
toast("Message sent", "success");
if (sendResult?.status === "pending" && sendResult.pending_send_id) {
notifyUndoSendStaged(sendResult.pending_send_id, Number(sendResult.undo_window_secs) || 0);
} else {
toast("Message sent", "success");
}
await loadFolders();
} catch (error) {
state.composeDirty = true;