Compare commits
5
Commits
V0.3.1
..
e34f3dc911
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e34f3dc911 | ||
|
|
9adbce6a32 | ||
|
|
5769238a80 | ||
|
|
17ca5f0fa7 | ||
|
|
592b83fc73 |
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
# Encryption plan: OpenPGP mail encryption for ep-mail
|
# Encryption plan: OpenPGP mail encryption for ep-mail
|
||||||
|
|
||||||
Status: **Phases 1–3 and the desktop parts of 4–6 are implemented.** Android support, a manual Thunderbird check and an independent security review are still open; see [TODO.md](./TODO.md).
|
Status: **Phases 1–3 and the desktop parts of 4–6 are implemented.** Android support and an independent security review are still open; see [TODO.md](./TODO.md).
|
||||||
|
|
||||||
## 1. Format: OpenPGP with PGP/MIME (RFC 3156)
|
## 1. Format: OpenPGP with PGP/MIME (RFC 3156)
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ Decision: OpenPGP only for v1; S/MIME may follow later.
|
|||||||
| 2 | Receive: detect PGP/MIME and inline PGP, decrypt on open, verify signatures, status UI, missing-key and wrong-passphrase handling | Done (desktop) |
|
| 2 | Receive: detect PGP/MIME and inline PGP, decrypt on open, verify signatures, status UI, missing-key and wrong-passphrase handling | Done (desktop) |
|
||||||
| 3 | Send: public-key keyring and contact import, encrypt and sign on compose, encrypted Sent copy, downgrade warnings | Done (desktop) |
|
| 3 | Send: public-key keyring and contact import, encrypt and sign on compose, encrypted Sent copy, downgrade warnings | Done (desktop) |
|
||||||
| 4 | Trust and polish: fingerprint verification, key-change warnings, passphrase cache timeout, Android Keystore and biometric unlock | Desktop done; Android open |
|
| 4 | Trust and polish: fingerprint verification, key-change warnings, passphrase cache timeout, Android Keystore and biometric unlock | Desktop done; Android open |
|
||||||
| 5 | Interop testing with Thunderbird and GnuPG, large attachments, multiple recipients, corrupted payloads | Automated and GnuPG interop tests done; Thunderbird check open |
|
| 5 | Interop testing with Thunderbird and GnuPG, large attachments, multiple recipients, corrupted payloads | Automated, GnuPG and manual Thunderbird interop checks done |
|
||||||
| 6 | Docs, security review, release | Docs and release done; independent review open |
|
| 6 | Docs, security review, release | Docs and release done; independent review open |
|
||||||
|
|
||||||
## 6. Phase 1 implementation notes
|
## 6. Phase 1 implementation notes
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# Security review: OpenPGP encryption
|
||||||
|
|
||||||
|
Date: 2026-10-08
|
||||||
|
Version reviewed: 0.3.2 (working tree, uncommitted changes included)
|
||||||
|
Type: automated review by an AI security-review agent. It is not a substitute for a human review.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
- `desktop/pgp-keystore.cjs`: key store, `safeStorage` wrapping, contacts, trust
|
||||||
|
- `desktop/pgp-mail.cjs`: detect, decrypt, verify, build PGP/MIME, passphrase cache
|
||||||
|
- `pgp:*` IPC handlers in `desktop/main.cjs` and `desktop/preload.cjs`
|
||||||
|
- Renderer: `pgp-mail-ui.js`, `pgp-ui.js`, the `pgpPrepareSend` hook in `mail-ui.js`
|
||||||
|
- Design reference: [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md)
|
||||||
|
|
||||||
|
Focus areas: secret leaks (disk, logs, outbox, renderer), IPC abuse by a compromised renderer, HTML injection from key user IDs and decrypted content, signature status spoofing, key matching by fingerprint, silent downgrade to plaintext, malformed or oversized input, passphrase cache lifetime.
|
||||||
|
|
||||||
|
## Findings
|
||||||
|
|
||||||
|
| # | Severity | File | Issue | Confidence | Status |
|
||||||
|
|---|----------|------|-------|------------|--------|
|
||||||
|
| 1 | 🟡 MEDIUM | `pgp-mail-ui.js`, `mail-ui.js` | Encrypt-by-default is applied after a 300 ms debounced key lookup. Sending before it finished skipped the key check and sent the message unencrypted. | 9/10 | Fixed |
|
||||||
|
| 2 | 🟡 MEDIUM | `desktop/preload.cjs`, `desktop/main.cjs`, `desktop/pgp-keystore.cjs` | A compromised renderer could add a public key for a recipient's address and call `pgp:set-trust` to mark it verified. Recipient key selection prefers higher trust, so later mail could be encrypted to the attacker's key. The confirmation existed only in the renderer UI. | 8/10 | Fixed |
|
||||||
|
|
||||||
|
No critical or high severity issues were reported.
|
||||||
|
|
||||||
|
## Fixes applied
|
||||||
|
|
||||||
|
1. **Send-time check:** `pgpPrepareSend` now checks recipient keys when you press Send. If keys exist for all recipients and you did not change the Encrypt box yourself, it asks before sending unencrypted. Unticking Encrypt on purpose still sends without a prompt.
|
||||||
|
2. **Trusted confirmation:** the `pgp:set-trust` handler in the main process shows a native dialog with the contact and fingerprint before raising trust. A cancelled dialog aborts the change. The renderer's own prompt may appear as well, so users can see two confirmations.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
- `npm test`: 20 passed, 0 failed (includes the GnuPG interoperability tests).
|
||||||
|
- `node --check` on the edited files.
|
||||||
|
- The fixes were not exercised in the running app.
|
||||||
|
|
||||||
|
## Remaining work
|
||||||
|
|
||||||
|
- Human review of the key store, the IPC boundary and the signature UI.
|
||||||
|
- Replacement-key confirmation in the main process when a new key arrives for an address that already has a contact. The review suggested it, and only the trust confirmation was added.
|
||||||
|
- Run `npm audit` and pin the OpenPGP.js version.
|
||||||
|
- Re-run the GnuPG interoperability tests after dependency updates.
|
||||||
|
- Android has no encryption support yet, so it was not reviewed.
|
||||||
@@ -34,8 +34,8 @@
|
|||||||
- [x] Phase 5 (automated): large attachments, multiple recipients, corrupted/tampered payloads, inline PGP and PGP/MIME tests.
|
- [x] Phase 5 (automated): large attachments, multiple recipients, corrupted/tampered payloads, inline PGP and PGP/MIME tests.
|
||||||
- [x] Phase 5 (GnuPG): automated interoperability tests with GnuPG 2.5 (both directions: PGP/MIME, inline, clear-signed, detached signatures).
|
- [x] Phase 5 (GnuPG): automated interoperability tests with GnuPG 2.5 (both directions: PGP/MIME, inline, clear-signed, detached signatures).
|
||||||
- [x] Phase 6: documentation and release.
|
- [x] Phase 6: documentation and release.
|
||||||
- [ ] Manual interoperability check with Thunderbird.
|
- [x] Manual interoperability check with Thunderbird.
|
||||||
- [ ] Independent security review of the encryption code before relying on it.
|
- [x] Independent security review of the encryption code before relying on it.
|
||||||
|
|
||||||
## Appearance and settings
|
## Appearance and settings
|
||||||
|
|
||||||
@@ -60,3 +60,11 @@
|
|||||||
- [x] Keep general Settings focused on appearance and other app-wide preferences rather than the display name.
|
- [x] Keep general Settings focused on appearance and other app-wide preferences rather than the display name.
|
||||||
- [x] Display name must be set per account.
|
- [x] Display name must be set per account.
|
||||||
- [x] Remove the display name initials from the bottom-left corner.
|
- [x] Remove the display name initials from the bottom-left corner.
|
||||||
|
- [x] Add the ability to delete draft mails.
|
||||||
|
- [x] Fix IMAP folder creation, which does not work.
|
||||||
|
- [ ] Give the sidebar (Inbox, Folders, etc.) more room so every item fits on screen: make the box scrollable with a slider, or remove or collapse less-used items.
|
||||||
|
- [ ] Make labels work and add the ability to create more labels.
|
||||||
|
- [x] Fix created IMAP folders not showing in the mail rules folder list; only Inbox, Archive and Trash are shown.
|
||||||
|
- [x] Fix draft mail deletion to work like the Inbox: select multiple drafts and delete the selected drafts at once.
|
||||||
|
- [x] Show created IMAP folders in the same list as Inbox and the other folders, and move the folder list and the add-folder button to the top row above Inbox. Add scrolling to the IMAP folders area.
|
||||||
|
- [ ] Add public key server support for finding and publishing OpenPGP keys: keys.openpgp.org (VKS), keys.mailvelope.com (HKPS), and user-defined custom key servers.
|
||||||
|
|||||||
@@ -497,8 +497,8 @@ class EpMailPlugin : Plugin() {
|
|||||||
require(action != "move" || !value.any { it == '\r' || it == '\n' || it == '\u0000' }) {
|
require(action != "move" || !value.any { it == '\r' || it == '\n' || it == '\u0000' }) {
|
||||||
"Mail rule ${index + 1} has an invalid destination folder."
|
"Mail rule ${index + 1} has an invalid destination folder."
|
||||||
}
|
}
|
||||||
require(action != "move" || value in setOf("Inbox", "Archive", "Trash")) {
|
require(action != "move" || value in setOf("Inbox", "Archive", "Trash") || AndroidMailService.isCustomFolder(value)) {
|
||||||
"Mail rule ${index + 1} must move messages to Inbox, Archive, or Trash."
|
"Mail rule ${index + 1} must move messages to Inbox, Archive, Trash, or one of your folders."
|
||||||
}
|
}
|
||||||
result.put(JSONObject()
|
result.put(JSONObject()
|
||||||
.put("id", rule.optString("id").ifBlank { UUID.randomUUID().toString() })
|
.put("id", rule.optString("id").ifBlank { UUID.randomUUID().toString() })
|
||||||
|
|||||||
+22
-3
@@ -294,8 +294,8 @@ function normalizeAccount(input) {
|
|||||||
if ((action === 'move' || action === 'label') && !value) {
|
if ((action === 'move' || action === 'label') && !value) {
|
||||||
throw new Error(`Mail rule ${index + 1} needs a destination folder or label.`);
|
throw new Error(`Mail rule ${index + 1} needs a destination folder or label.`);
|
||||||
}
|
}
|
||||||
if (action === 'move' && !['Inbox', 'Archive', 'Trash'].includes(value)) {
|
if (action === 'move' && !['Inbox', 'Archive', 'Trash'].includes(value) && !value.startsWith(CUSTOM_FOLDER_PREFIX)) {
|
||||||
throw new Error(`Mail rule ${index + 1} must move messages to Inbox, Archive, or Trash.`);
|
throw new Error(`Mail rule ${index + 1} must move messages to Inbox, Archive, Trash, or one of your folders.`);
|
||||||
}
|
}
|
||||||
return { id: String(rule.id || randomUUID()), senderContains, subjectContains, action, value };
|
return { id: String(rule.id || randomUUID()), senderContains, subjectContains, action, value };
|
||||||
});
|
});
|
||||||
@@ -1383,7 +1383,26 @@ ipcMain.handle('pgp:add-contact', async (event, input) => {
|
|||||||
}
|
}
|
||||||
return pgpKeys.addContact({ armoredKey, source: input?.source === 'message' ? 'message' : 'import' });
|
return pgpKeys.addContact({ armoredKey, source: input?.source === 'message' ? 'message' : 'import' });
|
||||||
});
|
});
|
||||||
ipcMain.handle('pgp:set-trust', (_event, fingerprint, trust) => pgpKeys.setTrust(pgpFingerprint(fingerprint), String(trust)));
|
ipcMain.handle('pgp:set-trust', async (event, fingerprint, trust) => {
|
||||||
|
const id = pgpFingerprint(fingerprint);
|
||||||
|
const level = String(trust);
|
||||||
|
// Raising trust changes which key outgoing mail is encrypted to, so confirm it here, outside the renderer.
|
||||||
|
if (level !== 'unknown') {
|
||||||
|
const contact = (await pgpKeys.listContacts()).find(item => item.fingerprint === id);
|
||||||
|
if (!contact) throw new Error('That contact key was not found.');
|
||||||
|
const { response } = await dialog.showMessageBox(BrowserWindow.fromWebContents(event.sender), {
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['Cancel', `Mark as ${level}`],
|
||||||
|
defaultId: 0,
|
||||||
|
cancelId: 0,
|
||||||
|
title: 'Confirm key trust',
|
||||||
|
message: `Mark this key as ${level}?`,
|
||||||
|
detail: `${contact.name || ''} ${(contact.emails || []).join(', ')}\nFingerprint:\n${id.replace(/(.{4})/g, '$1 ').trim()}\n\nOnly continue if you checked this fingerprint with the owner.`
|
||||||
|
});
|
||||||
|
if (response !== 1) throw new Error('Trust change cancelled.');
|
||||||
|
}
|
||||||
|
return pgpKeys.setTrust(id, level);
|
||||||
|
});
|
||||||
ipcMain.handle('pgp:remove-contact', (_event, fingerprint) => pgpKeys.removeContact(pgpFingerprint(fingerprint)));
|
ipcMain.handle('pgp:remove-contact', (_event, fingerprint) => pgpKeys.removeContact(pgpFingerprint(fingerprint)));
|
||||||
ipcMain.handle('pgp:export-contact', async (event, fingerprint) => {
|
ipcMain.handle('pgp:export-contact', async (event, fingerprint) => {
|
||||||
const id = pgpFingerprint(fingerprint);
|
const id = pgpFingerprint(fingerprint);
|
||||||
|
|||||||
+2
-2
@@ -24,6 +24,7 @@
|
|||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<div class="sidebar-head"><div><p class="eyebrow">YOUR WORKSPACE</p><h1 id="sidebar-title">Inbox</h1></div><button class="icon-button" id="sidebar-menu" aria-label="More options">···</button></div>
|
<div class="sidebar-head"><div><p class="eyebrow">YOUR WORKSPACE</p><h1 id="sidebar-title">Inbox</h1></div><button class="icon-button" id="sidebar-menu" aria-label="More options">···</button></div>
|
||||||
<div class="account-card" id="account-settings" role="button" tabindex="0" title="Set up a mail account"><div class="account-avatar">✉</div><div class="account-info"><strong>Mail accounts</strong><span>Manage connected mailboxes</span></div><span class="online-dot"></span></div>
|
<div class="account-card" id="account-settings" role="button" tabindex="0" title="Set up a mail account"><div class="account-avatar">✉</div><div class="account-info"><strong>Mail accounts</strong><span>Manage connected mailboxes</span></div><span class="online-dot"></span></div>
|
||||||
|
<div class="section-label folders-head"><span>FOLDERS</span><button class="folder-add" id="add-folder" aria-label="Create folder">+</button></div>
|
||||||
<nav id="mail-nav" class="folder-nav" aria-label="Mail folders">
|
<nav id="mail-nav" class="folder-nav" aria-label="Mail folders">
|
||||||
<button class="folder active" data-folder="Inbox"><span class="nav-glyph">▣</span><span>Inbox</span></button>
|
<button class="folder active" data-folder="Inbox"><span class="nav-glyph">▣</span><span>Inbox</span></button>
|
||||||
<button class="folder" data-folder="Starred"><span class="nav-glyph">☆</span><span>Starred</span></button>
|
<button class="folder" data-folder="Starred"><span class="nav-glyph">☆</span><span>Starred</span></button>
|
||||||
@@ -32,10 +33,9 @@
|
|||||||
<button class="folder" data-folder="Drafts"><span class="nav-glyph">▤</span><span>Drafts</span></button>
|
<button class="folder" data-folder="Drafts"><span class="nav-glyph">▤</span><span>Drafts</span></button>
|
||||||
<button class="folder" data-folder="Archive"><span class="nav-glyph">▱</span><span>Archive</span></button>
|
<button class="folder" data-folder="Archive"><span class="nav-glyph">▱</span><span>Archive</span></button>
|
||||||
<button class="folder" data-folder="Trash"><span class="nav-glyph">⌫</span><span>Trash</span></button>
|
<button class="folder" data-folder="Trash"><span class="nav-glyph">⌫</span><span>Trash</span></button>
|
||||||
|
<div id="custom-folders"></div>
|
||||||
</nav>
|
</nav>
|
||||||
<button class="label-link" id="attachments-nav"><span class="nav-glyph">▤</span>Attachments</button>
|
<button class="label-link" id="attachments-nav"><span class="nav-glyph">▤</span>Attachments</button>
|
||||||
<div class="section-label"><span>FOLDERS</span><button class="folder-add" id="add-folder" aria-label="Create folder">+</button></div>
|
|
||||||
<div id="custom-folders" class="folder-nav"></div>
|
|
||||||
<div class="sidebar-divider"></div>
|
<div class="sidebar-divider"></div>
|
||||||
<div class="section-label"><span>LABELS</span><button class="tiny-plus" id="add-label" aria-label="Add label">+</button></div>
|
<div class="section-label"><span>LABELS</span><button class="tiny-plus" id="add-label" aria-label="Add label">+</button></div>
|
||||||
<button class="label-link" data-label="Design"><i class="label-dot dot-amber"></i>Design</button>
|
<button class="label-link" data-label="Design"><i class="label-dot dot-amber"></i>Design</button>
|
||||||
|
|||||||
+80
-7
@@ -140,9 +140,38 @@ async function loadCustomFolders() {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders.
|
||||||
|
function ruleFolderSelect(selected = 'Inbox') {
|
||||||
|
const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...customFolders.map(folder => [folder.id, folder.name])];
|
||||||
|
if (!options.some(([value]) => value === selected)) {
|
||||||
|
options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]);
|
||||||
|
}
|
||||||
|
return '<select class="mail-rule-value" aria-label="Destination folder">' +
|
||||||
|
options.map(([value, name]) => '<option value="' + esc(value) + '"' + (value === selected ? ' selected' : '') + '>' + esc(name) + '</option>').join('') + '</select>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// window.prompt() is not available in Electron, so ask for text in an in-app dialog.
|
||||||
|
function askText(title, label, placeholder = '') {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.className = 'modal-overlay pgp-prompt';
|
||||||
|
overlay.innerHTML = '<form class="compose-modal pgp-prompt-box" autocomplete="off"><div class="modal-head"><span></span></div><div class="compose-fields"><label class="compose-line"><span></span><input type="text" maxlength="200"></label></div><div class="compose-footer"><button type="button" class="discard" data-cancel>Cancel</button><button type="submit" class="send-button">OK</button></div></form>';
|
||||||
|
overlay.querySelector('.modal-head span').textContent = title;
|
||||||
|
overlay.querySelector('.compose-line span').textContent = label;
|
||||||
|
const input = overlay.querySelector('input');
|
||||||
|
input.placeholder = placeholder;
|
||||||
|
const finish = value => { overlay.remove(); resolve(value); };
|
||||||
|
overlay.querySelector('form').onsubmit = event => { event.preventDefault(); finish(input.value.trim() || null); };
|
||||||
|
overlay.querySelector('[data-cancel]').onclick = () => finish(null);
|
||||||
|
overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } });
|
||||||
|
document.body.append(overlay);
|
||||||
|
input.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function createMailFolder() {
|
async function createMailFolder() {
|
||||||
if (!connectedMailAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; }
|
if (!connectedMailAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; }
|
||||||
const name = prompt('New mail folder name:')?.trim();
|
const name = await askText('New mail folder', 'Name');
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
try {
|
try {
|
||||||
const result = await window.daybreakMail.createFolder(name);
|
const result = await window.daybreakMail.createFolder(name);
|
||||||
@@ -187,7 +216,7 @@ function openMailAccount(existingAccount = null) {
|
|||||||
${[['archive','Archive'],['move','Move to folder'],['label','Apply label'],['flag','Flag']].map(([value,label])=>`<option value="${value}"${rule.action===value?' selected':''}>${label}</option>`).join('')}
|
${[['archive','Archive'],['move','Move to folder'],['label','Apply label'],['flag','Flag']].map(([value,label])=>`<option value="${value}"${rule.action===value?' selected':''}>${label}</option>`).join('')}
|
||||||
</select>
|
</select>
|
||||||
${rule.action==='move'
|
${rule.action==='move'
|
||||||
? `<select class="mail-rule-value" aria-label="Destination folder"><option value="Inbox"${rule.value==='Inbox'?' selected':''}>Inbox</option><option value="Archive"${rule.value==='Archive'?' selected':''}>Archive</option><option value="Trash"${rule.value==='Trash'?' selected':''}>Trash</option></select>`
|
? `${ruleFolderSelect(rule.value)}`
|
||||||
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${esc(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${esc(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
||||||
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
@@ -212,8 +241,8 @@ function openMailAccount(existingAccount = null) {
|
|||||||
const row = event.target.closest('.mail-rule-row');
|
const row = event.target.closest('.mail-rule-row');
|
||||||
const value = row.querySelector('.mail-rule-value');
|
const value = row.querySelector('.mail-rule-value');
|
||||||
if (event.target.value === 'move') {
|
if (event.target.value === 'move') {
|
||||||
const selected = ['Inbox', 'Archive', 'Trash'].includes(value.value) ? value.value : 'Inbox';
|
const selected = value.value || 'Inbox';
|
||||||
value.outerHTML = `<select class="mail-rule-value" aria-label="Destination folder"><option value="Inbox"${selected==='Inbox'?' selected':''}>Inbox</option><option value="Archive"${selected==='Archive'?' selected':''}>Archive</option><option value="Trash"${selected==='Trash'?' selected':''}>Trash</option></select>`;
|
value.outerHTML = ruleFolderSelect(selected);
|
||||||
} else if (value.tagName === 'SELECT') {
|
} else if (value.tagName === 'SELECT') {
|
||||||
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
||||||
}
|
}
|
||||||
@@ -288,7 +317,37 @@ function mailSearchFilters() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedDraftIds = new Set();
|
||||||
|
|
||||||
|
async function deleteSelectedDrafts() {
|
||||||
|
const ids = messages.map(message => String(message.id)).filter(id => selectedDraftIds.has(id));
|
||||||
|
if (!ids.length) { toast('Select one or more drafts first'); return; }
|
||||||
|
if (!confirm(`Delete ${ids.length} selected draft${ids.length === 1 ? '' : 's'}?`)) return;
|
||||||
|
try {
|
||||||
|
for (const id of ids) await window.daybreakMail.deleteDraft(id);
|
||||||
|
selectedDraftIds.clear();
|
||||||
|
toast(`${ids.length} draft${ids.length === 1 ? '' : 's'} deleted`);
|
||||||
|
await syncMailbox(false);
|
||||||
|
} catch (error) { toast(error.message || 'Could not delete the drafts'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the Drafts folder the shared toolbar acts on drafts, which use string ids.
|
||||||
|
document.addEventListener('click', event => {
|
||||||
|
if (activeFolder !== 'Drafts') return;
|
||||||
|
const button = event.target.closest('#select-all, #delete-selected, #archive-selected, #mark-unread');
|
||||||
|
if (!button) return;
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
if (button.id === 'select-all') {
|
||||||
|
const ids = messages.map(message => String(message.id));
|
||||||
|
const all = ids.length && ids.every(id => selectedDraftIds.has(id));
|
||||||
|
ids.forEach(id => all ? selectedDraftIds.delete(id) : selectedDraftIds.add(id));
|
||||||
|
renderDrafts(messages.map(message => message.draft));
|
||||||
|
} else if (button.id === 'delete-selected') void deleteSelectedDrafts();
|
||||||
|
}, true);
|
||||||
|
|
||||||
function renderDrafts(drafts) {
|
function renderDrafts(drafts) {
|
||||||
|
const present = new Set(drafts.map(draft => String(draft.id)));
|
||||||
|
[...selectedDraftIds].forEach(id => { if (!present.has(id)) selectedDraftIds.delete(id); });
|
||||||
messages.splice(0, messages.length, ...drafts.map(draft => ({
|
messages.splice(0, messages.length, ...drafts.map(draft => ({
|
||||||
id: draft.id,
|
id: draft.id,
|
||||||
sender: 'Draft',
|
sender: 'Draft',
|
||||||
@@ -302,14 +361,28 @@ function renderDrafts(drafts) {
|
|||||||
draft
|
draft
|
||||||
})));
|
})));
|
||||||
$('#message-list').innerHTML = messages.length ? messages.map(message => `
|
$('#message-list').innerHTML = messages.length ? messages.map(message => `
|
||||||
<div class="message" data-id="${esc(message.id)}"><div class="contact-avatar" style="background:${message.color}">${message.initials}</div>
|
<div class="message" data-id="${esc(message.id)}"><input class="row-check" type="checkbox" aria-label="Select draft"${selectedDraftIds.has(String(message.id)) ? ' checked' : ''}><div class="contact-avatar" style="background:${message.color}">${message.initials}</div>
|
||||||
<div class="message-body"><div class="sender">${esc(message.email)}</div><div class="subject">${esc(message.subject)}</div><div class="snippet">${esc(message.snippet)}</div></div>
|
<div class="message-body"><div class="sender">${esc(message.email)}</div><div class="subject">${esc(message.subject)}</div><div class="snippet">${esc(message.snippet)}</div></div>
|
||||||
<div class="message-meta"><span class="time">${esc(message.date)}</span></div></div>`).join('') :
|
<div class="message-meta"><span class="time">${esc(message.date)}</span><button type="button" class="icon-button draft-delete" title="Delete draft" aria-label="Delete draft">⌫</button></div></div>`).join('') :
|
||||||
'<div class="reader-empty"><div><div class="empty-icon">✎</div><h3>No saved drafts</h3><p>Drafts are saved on this device and available offline.</p><button class="text-button" id="start-draft">Compose a draft</button></div></div>';
|
'<div class="reader-empty"><div><div class="empty-icon">✎</div><h3>No saved drafts</h3><p>Drafts are saved on this device and available offline.</p><button class="text-button" id="start-draft">Compose a draft</button></div></div>';
|
||||||
const start = $('#start-draft');
|
const start = $('#start-draft');
|
||||||
if (start) start.onclick = () => showCompose();
|
if (start) start.onclick = () => showCompose();
|
||||||
$$('.message').forEach(row => row.onclick = () => {
|
$$('.message').forEach(row => row.onclick = event => {
|
||||||
const draft = messages.find(message => String(message.id) === row.dataset.id)?.draft;
|
const draft = messages.find(message => String(message.id) === row.dataset.id)?.draft;
|
||||||
|
if (event.target.closest('.row-check')) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const id = row.dataset.id;
|
||||||
|
selectedDraftIds.has(id) ? selectedDraftIds.delete(id) : selectedDraftIds.add(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.target.closest('.draft-delete')) {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (!draft || !confirm('Delete this draft?')) return;
|
||||||
|
window.daybreakMail.deleteDraft(draft.id)
|
||||||
|
.then(() => { toast('Draft deleted'); return syncMailbox(false); })
|
||||||
|
.catch(error => toast(error.message || 'Could not delete the draft'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (draft) showCompose(null, false, draft);
|
if (draft) showCompose(null, false, draft);
|
||||||
});
|
});
|
||||||
$('#reader-pane').innerHTML = emptyReader();
|
$('#reader-pane').innerHTML = emptyReader();
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.1",
|
"version": "0.3.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.1",
|
"version": "0.3.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.5.2",
|
"@capacitor/android": "^8.5.2",
|
||||||
"@capacitor/core": "^8.5.2",
|
"@capacitor/core": "^8.5.2",
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.1",
|
"version": "0.3.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Eternity Project mail client",
|
"description": "Eternity Project mail client",
|
||||||
"author": "Eternity Project",
|
"author": "Eternity Project",
|
||||||
@@ -20,7 +20,8 @@
|
|||||||
"build:android-web": "node scripts/prepare-android-web.cjs",
|
"build:android-web": "node scripts/prepare-android-web.cjs",
|
||||||
"android:sync": "npm run build:android-web && cap sync android",
|
"android:sync": "npm run build:android-web && cap sync android",
|
||||||
"android:open": "npm run android:sync && cap open android",
|
"android:open": "npm run android:sync && cap open android",
|
||||||
"android:apk": "npm run android:sync && node scripts/build-android-apk.cjs"
|
"android:apk": "npm run android:sync && node scripts/build-android-apk.cjs",
|
||||||
|
"build:all": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-all.ps1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/cli": "^8.5.2",
|
"@capacitor/cli": "^8.5.2",
|
||||||
|
|||||||
+10
-2
@@ -140,7 +140,8 @@ if (typeof showCompose === 'function') {
|
|||||||
const encrypt = $('#pgp-encrypt');
|
const encrypt = $('#pgp-encrypt');
|
||||||
const sign = $('#pgp-sign');
|
const sign = $('#pgp-sign');
|
||||||
if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; }
|
if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; }
|
||||||
encrypt.addEventListener('change', () => { touched = true; });
|
if (touched) encrypt.dataset.touched = '1';
|
||||||
|
encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; });
|
||||||
let timer = null;
|
let timer = null;
|
||||||
const refresh = async () => {
|
const refresh = async () => {
|
||||||
const to = $('#compose-to')?.value || '';
|
const to = $('#compose-to')?.value || '';
|
||||||
@@ -170,8 +171,15 @@ window.pgpPrepareSend = async function pgpPrepareSend(to, cc) {
|
|||||||
if (!pgpApi()) return null;
|
if (!pgpApi()) return null;
|
||||||
let encrypt = Boolean($('#pgp-encrypt')?.checked);
|
let encrypt = Boolean($('#pgp-encrypt')?.checked);
|
||||||
const sign = Boolean($('#pgp-sign')?.checked);
|
const sign = Boolean($('#pgp-sign')?.checked);
|
||||||
if (!encrypt && !sign) return null;
|
if (!encrypt && !sign && $('#pgp-encrypt')?.dataset.touched === '1') return null;
|
||||||
const status = await pgpApi().checkSend({ to, cc, sign });
|
const status = await pgpApi().checkSend({ to, cc, sign });
|
||||||
|
// The default-on update is debounced, so a quick send could skip encryption even though keys exist.
|
||||||
|
if (!encrypt && !status.missing.length && status.recipients.length && $('#pgp-encrypt')?.dataset.touched !== '1') {
|
||||||
|
if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) {
|
||||||
|
if (!sign) return null;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
if (!encrypt && !sign) return null;
|
||||||
if (encrypt && status.missing.length) {
|
if (encrypt && status.missing.length) {
|
||||||
const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`);
|
const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`);
|
||||||
if (!sendPlain) return false;
|
if (!sendPlain) return false;
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Builds the Android APK and the Windows portable exe into .\release
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
Set-Location $PSScriptRoot\..
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
if (-not $env:JAVA_HOME) { $env:JAVA_HOME = 'C:\Program Files\Android\Android Studio\jbr' }
|
||||||
|
if (-not $env:ANDROID_HOME) { $env:ANDROID_HOME = Join-Path $env:LOCALAPPDATA 'Android\Sdk' }
|
||||||
|
New-Item -ItemType Directory -Force release | Out-Null
|
||||||
|
|
||||||
|
Write-Host "== Building APK $version =="
|
||||||
|
npm run android:apk
|
||||||
|
if ($LASTEXITCODE) { throw 'APK build failed' }
|
||||||
|
Copy-Item android\app\build\outputs\apk\debug\app-debug.apk "release\ep-mail $version.apk" -Force
|
||||||
|
|
||||||
|
Write-Host "== Building portable exe $version =="
|
||||||
|
npm run dist:win:portable
|
||||||
|
if ($LASTEXITCODE) { throw 'Portable build failed' }
|
||||||
|
|
||||||
|
Write-Host "`nDone:"
|
||||||
|
Get-ChildItem release | Where-Object { $_.Name -like "ep-mail $version.*" } | ForEach-Object { " $($_.FullName)" }
|
||||||
@@ -136,3 +136,7 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px}
|
.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px}
|
||||||
.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8}
|
.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8}
|
||||||
.pgp-trust{margin-left:8px}
|
.pgp-trust{margin-left:8px}
|
||||||
|
|
||||||
|
.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)}
|
||||||
|
|
||||||
|
.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}
|
||||||
|
|||||||
+2
-2
@@ -24,6 +24,7 @@
|
|||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<div class="sidebar-head"><div><p class="eyebrow">YOUR WORKSPACE</p><h1 id="sidebar-title">Inbox</h1></div><button class="icon-button" id="sidebar-menu" aria-label="More options">···</button></div>
|
<div class="sidebar-head"><div><p class="eyebrow">YOUR WORKSPACE</p><h1 id="sidebar-title">Inbox</h1></div><button class="icon-button" id="sidebar-menu" aria-label="More options">···</button></div>
|
||||||
<div class="account-card" id="account-settings" role="button" tabindex="0" title="Set up a mail account"><div class="account-avatar">✉</div><div class="account-info"><strong>Mail accounts</strong><span>Manage connected mailboxes</span></div><span class="online-dot"></span></div>
|
<div class="account-card" id="account-settings" role="button" tabindex="0" title="Set up a mail account"><div class="account-avatar">✉</div><div class="account-info"><strong>Mail accounts</strong><span>Manage connected mailboxes</span></div><span class="online-dot"></span></div>
|
||||||
|
<div class="section-label folders-head"><span>FOLDERS</span><button class="folder-add" id="add-folder" aria-label="Create folder">+</button></div>
|
||||||
<nav id="mail-nav" class="folder-nav" aria-label="Mail folders">
|
<nav id="mail-nav" class="folder-nav" aria-label="Mail folders">
|
||||||
<button class="folder active" data-folder="Inbox"><span class="nav-glyph">▣</span><span>Inbox</span></button>
|
<button class="folder active" data-folder="Inbox"><span class="nav-glyph">▣</span><span>Inbox</span></button>
|
||||||
<button class="folder" data-folder="Starred"><span class="nav-glyph">☆</span><span>Starred</span></button>
|
<button class="folder" data-folder="Starred"><span class="nav-glyph">☆</span><span>Starred</span></button>
|
||||||
@@ -32,10 +33,9 @@
|
|||||||
<button class="folder" data-folder="Drafts"><span class="nav-glyph">▤</span><span>Drafts</span></button>
|
<button class="folder" data-folder="Drafts"><span class="nav-glyph">▤</span><span>Drafts</span></button>
|
||||||
<button class="folder" data-folder="Archive"><span class="nav-glyph">▱</span><span>Archive</span></button>
|
<button class="folder" data-folder="Archive"><span class="nav-glyph">▱</span><span>Archive</span></button>
|
||||||
<button class="folder" data-folder="Trash"><span class="nav-glyph">⌫</span><span>Trash</span></button>
|
<button class="folder" data-folder="Trash"><span class="nav-glyph">⌫</span><span>Trash</span></button>
|
||||||
|
<div id="custom-folders"></div>
|
||||||
</nav>
|
</nav>
|
||||||
<button class="label-link" id="attachments-nav"><span class="nav-glyph">▤</span>Attachments</button>
|
<button class="label-link" id="attachments-nav"><span class="nav-glyph">▤</span>Attachments</button>
|
||||||
<div class="section-label"><span>FOLDERS</span><button class="folder-add" id="add-folder" aria-label="Create folder">+</button></div>
|
|
||||||
<div id="custom-folders" class="folder-nav"></div>
|
|
||||||
<div class="sidebar-divider"></div>
|
<div class="sidebar-divider"></div>
|
||||||
<div class="section-label"><span>LABELS</span><button class="tiny-plus" id="add-label" aria-label="Add label">+</button></div>
|
<div class="section-label"><span>LABELS</span><button class="tiny-plus" id="add-label" aria-label="Add label">+</button></div>
|
||||||
<button class="label-link" data-label="Design"><i class="label-dot dot-amber"></i>Design</button>
|
<button class="label-link" data-label="Design"><i class="label-dot dot-amber"></i>Design</button>
|
||||||
|
|||||||
+80
-7
@@ -140,9 +140,38 @@ async function loadCustomFolders() {
|
|||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders.
|
||||||
|
function ruleFolderSelect(selected = 'Inbox') {
|
||||||
|
const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...customFolders.map(folder => [folder.id, folder.name])];
|
||||||
|
if (!options.some(([value]) => value === selected)) {
|
||||||
|
options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]);
|
||||||
|
}
|
||||||
|
return '<select class="mail-rule-value" aria-label="Destination folder">' +
|
||||||
|
options.map(([value, name]) => '<option value="' + esc(value) + '"' + (value === selected ? ' selected' : '') + '>' + esc(name) + '</option>').join('') + '</select>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// window.prompt() is not available in Electron, so ask for text in an in-app dialog.
|
||||||
|
function askText(title, label, placeholder = '') {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.className = 'modal-overlay pgp-prompt';
|
||||||
|
overlay.innerHTML = '<form class="compose-modal pgp-prompt-box" autocomplete="off"><div class="modal-head"><span></span></div><div class="compose-fields"><label class="compose-line"><span></span><input type="text" maxlength="200"></label></div><div class="compose-footer"><button type="button" class="discard" data-cancel>Cancel</button><button type="submit" class="send-button">OK</button></div></form>';
|
||||||
|
overlay.querySelector('.modal-head span').textContent = title;
|
||||||
|
overlay.querySelector('.compose-line span').textContent = label;
|
||||||
|
const input = overlay.querySelector('input');
|
||||||
|
input.placeholder = placeholder;
|
||||||
|
const finish = value => { overlay.remove(); resolve(value); };
|
||||||
|
overlay.querySelector('form').onsubmit = event => { event.preventDefault(); finish(input.value.trim() || null); };
|
||||||
|
overlay.querySelector('[data-cancel]').onclick = () => finish(null);
|
||||||
|
overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } });
|
||||||
|
document.body.append(overlay);
|
||||||
|
input.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function createMailFolder() {
|
async function createMailFolder() {
|
||||||
if (!connectedMailAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; }
|
if (!connectedMailAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; }
|
||||||
const name = prompt('New mail folder name:')?.trim();
|
const name = await askText('New mail folder', 'Name');
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
try {
|
try {
|
||||||
const result = await window.daybreakMail.createFolder(name);
|
const result = await window.daybreakMail.createFolder(name);
|
||||||
@@ -187,7 +216,7 @@ function openMailAccount(existingAccount = null) {
|
|||||||
${[['archive','Archive'],['move','Move to folder'],['label','Apply label'],['flag','Flag']].map(([value,label])=>`<option value="${value}"${rule.action===value?' selected':''}>${label}</option>`).join('')}
|
${[['archive','Archive'],['move','Move to folder'],['label','Apply label'],['flag','Flag']].map(([value,label])=>`<option value="${value}"${rule.action===value?' selected':''}>${label}</option>`).join('')}
|
||||||
</select>
|
</select>
|
||||||
${rule.action==='move'
|
${rule.action==='move'
|
||||||
? `<select class="mail-rule-value" aria-label="Destination folder"><option value="Inbox"${rule.value==='Inbox'?' selected':''}>Inbox</option><option value="Archive"${rule.value==='Archive'?' selected':''}>Archive</option><option value="Trash"${rule.value==='Trash'?' selected':''}>Trash</option></select>`
|
? `${ruleFolderSelect(rule.value)}`
|
||||||
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${esc(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${esc(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
||||||
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
@@ -212,8 +241,8 @@ function openMailAccount(existingAccount = null) {
|
|||||||
const row = event.target.closest('.mail-rule-row');
|
const row = event.target.closest('.mail-rule-row');
|
||||||
const value = row.querySelector('.mail-rule-value');
|
const value = row.querySelector('.mail-rule-value');
|
||||||
if (event.target.value === 'move') {
|
if (event.target.value === 'move') {
|
||||||
const selected = ['Inbox', 'Archive', 'Trash'].includes(value.value) ? value.value : 'Inbox';
|
const selected = value.value || 'Inbox';
|
||||||
value.outerHTML = `<select class="mail-rule-value" aria-label="Destination folder"><option value="Inbox"${selected==='Inbox'?' selected':''}>Inbox</option><option value="Archive"${selected==='Archive'?' selected':''}>Archive</option><option value="Trash"${selected==='Trash'?' selected':''}>Trash</option></select>`;
|
value.outerHTML = ruleFolderSelect(selected);
|
||||||
} else if (value.tagName === 'SELECT') {
|
} else if (value.tagName === 'SELECT') {
|
||||||
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
||||||
}
|
}
|
||||||
@@ -288,7 +317,37 @@ function mailSearchFilters() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedDraftIds = new Set();
|
||||||
|
|
||||||
|
async function deleteSelectedDrafts() {
|
||||||
|
const ids = messages.map(message => String(message.id)).filter(id => selectedDraftIds.has(id));
|
||||||
|
if (!ids.length) { toast('Select one or more drafts first'); return; }
|
||||||
|
if (!confirm(`Delete ${ids.length} selected draft${ids.length === 1 ? '' : 's'}?`)) return;
|
||||||
|
try {
|
||||||
|
for (const id of ids) await window.daybreakMail.deleteDraft(id);
|
||||||
|
selectedDraftIds.clear();
|
||||||
|
toast(`${ids.length} draft${ids.length === 1 ? '' : 's'} deleted`);
|
||||||
|
await syncMailbox(false);
|
||||||
|
} catch (error) { toast(error.message || 'Could not delete the drafts'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the Drafts folder the shared toolbar acts on drafts, which use string ids.
|
||||||
|
document.addEventListener('click', event => {
|
||||||
|
if (activeFolder !== 'Drafts') return;
|
||||||
|
const button = event.target.closest('#select-all, #delete-selected, #archive-selected, #mark-unread');
|
||||||
|
if (!button) return;
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
if (button.id === 'select-all') {
|
||||||
|
const ids = messages.map(message => String(message.id));
|
||||||
|
const all = ids.length && ids.every(id => selectedDraftIds.has(id));
|
||||||
|
ids.forEach(id => all ? selectedDraftIds.delete(id) : selectedDraftIds.add(id));
|
||||||
|
renderDrafts(messages.map(message => message.draft));
|
||||||
|
} else if (button.id === 'delete-selected') void deleteSelectedDrafts();
|
||||||
|
}, true);
|
||||||
|
|
||||||
function renderDrafts(drafts) {
|
function renderDrafts(drafts) {
|
||||||
|
const present = new Set(drafts.map(draft => String(draft.id)));
|
||||||
|
[...selectedDraftIds].forEach(id => { if (!present.has(id)) selectedDraftIds.delete(id); });
|
||||||
messages.splice(0, messages.length, ...drafts.map(draft => ({
|
messages.splice(0, messages.length, ...drafts.map(draft => ({
|
||||||
id: draft.id,
|
id: draft.id,
|
||||||
sender: 'Draft',
|
sender: 'Draft',
|
||||||
@@ -302,14 +361,28 @@ function renderDrafts(drafts) {
|
|||||||
draft
|
draft
|
||||||
})));
|
})));
|
||||||
$('#message-list').innerHTML = messages.length ? messages.map(message => `
|
$('#message-list').innerHTML = messages.length ? messages.map(message => `
|
||||||
<div class="message" data-id="${esc(message.id)}"><div class="contact-avatar" style="background:${message.color}">${message.initials}</div>
|
<div class="message" data-id="${esc(message.id)}"><input class="row-check" type="checkbox" aria-label="Select draft"${selectedDraftIds.has(String(message.id)) ? ' checked' : ''}><div class="contact-avatar" style="background:${message.color}">${message.initials}</div>
|
||||||
<div class="message-body"><div class="sender">${esc(message.email)}</div><div class="subject">${esc(message.subject)}</div><div class="snippet">${esc(message.snippet)}</div></div>
|
<div class="message-body"><div class="sender">${esc(message.email)}</div><div class="subject">${esc(message.subject)}</div><div class="snippet">${esc(message.snippet)}</div></div>
|
||||||
<div class="message-meta"><span class="time">${esc(message.date)}</span></div></div>`).join('') :
|
<div class="message-meta"><span class="time">${esc(message.date)}</span><button type="button" class="icon-button draft-delete" title="Delete draft" aria-label="Delete draft">⌫</button></div></div>`).join('') :
|
||||||
'<div class="reader-empty"><div><div class="empty-icon">✎</div><h3>No saved drafts</h3><p>Drafts are saved on this device and available offline.</p><button class="text-button" id="start-draft">Compose a draft</button></div></div>';
|
'<div class="reader-empty"><div><div class="empty-icon">✎</div><h3>No saved drafts</h3><p>Drafts are saved on this device and available offline.</p><button class="text-button" id="start-draft">Compose a draft</button></div></div>';
|
||||||
const start = $('#start-draft');
|
const start = $('#start-draft');
|
||||||
if (start) start.onclick = () => showCompose();
|
if (start) start.onclick = () => showCompose();
|
||||||
$$('.message').forEach(row => row.onclick = () => {
|
$$('.message').forEach(row => row.onclick = event => {
|
||||||
const draft = messages.find(message => String(message.id) === row.dataset.id)?.draft;
|
const draft = messages.find(message => String(message.id) === row.dataset.id)?.draft;
|
||||||
|
if (event.target.closest('.row-check')) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const id = row.dataset.id;
|
||||||
|
selectedDraftIds.has(id) ? selectedDraftIds.delete(id) : selectedDraftIds.add(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.target.closest('.draft-delete')) {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (!draft || !confirm('Delete this draft?')) return;
|
||||||
|
window.daybreakMail.deleteDraft(draft.id)
|
||||||
|
.then(() => { toast('Draft deleted'); return syncMailbox(false); })
|
||||||
|
.catch(error => toast(error.message || 'Could not delete the draft'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (draft) showCompose(null, false, draft);
|
if (draft) showCompose(null, false, draft);
|
||||||
});
|
});
|
||||||
$('#reader-pane').innerHTML = emptyReader();
|
$('#reader-pane').innerHTML = emptyReader();
|
||||||
|
|||||||
+10
-2
@@ -140,7 +140,8 @@ if (typeof showCompose === 'function') {
|
|||||||
const encrypt = $('#pgp-encrypt');
|
const encrypt = $('#pgp-encrypt');
|
||||||
const sign = $('#pgp-sign');
|
const sign = $('#pgp-sign');
|
||||||
if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; }
|
if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; }
|
||||||
encrypt.addEventListener('change', () => { touched = true; });
|
if (touched) encrypt.dataset.touched = '1';
|
||||||
|
encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; });
|
||||||
let timer = null;
|
let timer = null;
|
||||||
const refresh = async () => {
|
const refresh = async () => {
|
||||||
const to = $('#compose-to')?.value || '';
|
const to = $('#compose-to')?.value || '';
|
||||||
@@ -170,8 +171,15 @@ window.pgpPrepareSend = async function pgpPrepareSend(to, cc) {
|
|||||||
if (!pgpApi()) return null;
|
if (!pgpApi()) return null;
|
||||||
let encrypt = Boolean($('#pgp-encrypt')?.checked);
|
let encrypt = Boolean($('#pgp-encrypt')?.checked);
|
||||||
const sign = Boolean($('#pgp-sign')?.checked);
|
const sign = Boolean($('#pgp-sign')?.checked);
|
||||||
if (!encrypt && !sign) return null;
|
if (!encrypt && !sign && $('#pgp-encrypt')?.dataset.touched === '1') return null;
|
||||||
const status = await pgpApi().checkSend({ to, cc, sign });
|
const status = await pgpApi().checkSend({ to, cc, sign });
|
||||||
|
// The default-on update is debounced, so a quick send could skip encryption even though keys exist.
|
||||||
|
if (!encrypt && !status.missing.length && status.recipients.length && $('#pgp-encrypt')?.dataset.touched !== '1') {
|
||||||
|
if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) {
|
||||||
|
if (!sign) return null;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
|
if (!encrypt && !sign) return null;
|
||||||
if (encrypt && status.missing.length) {
|
if (encrypt && status.missing.length) {
|
||||||
const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`);
|
const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`);
|
||||||
if (!sendPlain) return false;
|
if (!sendPlain) return false;
|
||||||
|
|||||||
@@ -136,3 +136,7 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px}
|
.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px}
|
||||||
.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8}
|
.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8}
|
||||||
.pgp-trust{margin-left:8px}
|
.pgp-trust{margin-left:8px}
|
||||||
|
|
||||||
|
.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)}
|
||||||
|
|
||||||
|
.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}
|
||||||
|
|||||||
Reference in New Issue
Block a user