Refractoring Stage 6.5 Migrated the snooze, attachment, and OpenPGP mail UI to the explicit mail feature API.

This commit is contained in:
2026-10-16 20:31:59 +03:00
parent f19573a337
commit 84a63441ef
14 changed files with 178 additions and 108 deletions
+9 -8
View File
@@ -1,4 +1,8 @@
// Attachment previews and a dedicated view for finding and managing attachments across mailboxes.
const mailUi = window.epMailFeatures.mail;
const $ = mailUi.select;
const $$ = mailUi.selectAll;
const toast = mailUi.toast;
const attachmentFolders = ['Inbox', 'Sent', 'Archive', 'Trash'];
let attachmentItems = [];
@@ -52,11 +56,9 @@ function downloadAttachment(details) {
}
// Add a Preview button to each attachment in the reader.
if (typeof openMessage === 'function') {
const baseOpenMessage = openMessage;
openMessage = function (id) {
mailUi.wrapOpenMessage(baseOpenMessage => function (id) {
baseOpenMessage(id);
const message = messages.find(item => item.id === id);
const message = mailUi.state.messages.find(item => item.id === id);
if (!message?.uid) return;
$$('#reader-pane .attachment').forEach(row => {
const download = row.querySelector('.download');
@@ -73,12 +75,11 @@ if (typeof openMessage === 'function') {
panel = document.createElement('div');
panel.className = 'attachment-preview';
row.after(panel);
void previewAttachment(panel, { uid: message.uid, folder: message.sourceFolder || activeFolder, filename: download.dataset.filename });
void previewAttachment(panel, { uid: message.uid, folder: message.sourceFolder || mailUi.state.activeFolder, filename: download.dataset.filename });
});
download.before(button);
});
};
}
});
async function collectAttachments() {
const items = [];
@@ -103,7 +104,7 @@ async function collectAttachments() {
}
async function openAttachmentsView() {
if (!connectedMailAccount || !window.daybreakMail) { openMailAccount(); return; }
if (!mailUi.connectedAccount || !window.daybreakMail) { mailUi.openMailAccount(); return; }
const root = $('#modal-root');
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal attachments-modal"><div class="modal-head"><span>Attachments</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><div class="attachment-toolbar"><input id="attachment-search" placeholder="Search file, subject, or sender"><select id="attachment-type" aria-label="File type"><option value="">All types</option><option>Images</option><option>Documents</option><option>Archives</option><option>Other</option></select></div><div id="attachment-list" class="attachment-list">Loading attachments…</div></div></div></div>`;
const close = () => { root.innerHTML = ''; };