Ver V0.1.12
This commit is contained in:
@@ -13,10 +13,12 @@
|
||||
|
||||
- [x] Make **EP Wasteland** the default theme for new users.
|
||||
- [x] Move theme selection into Settings and save the selection so the chosen theme is applied every time the program starts.
|
||||
- [x] Move the display name field from general Settings into Account Settings.
|
||||
- [x] Keep the display name in Account Settings and make it available while adding a mailbox.
|
||||
|
||||
## Account settings
|
||||
|
||||
- [ ] Add an **Edit** button for each connected mail account so its account settings can be changed after setup.
|
||||
- [x] Add an **Edit** button for each connected mail account so its account settings can be changed after setup.
|
||||
- [ ] Move CalDAV and CardDAV server configuration into Account Settings, removing the server settings controls from the Calendar and Contacts views.
|
||||
- [x] Keep general Settings focused on appearance and other app-wide preferences rather than the display name.
|
||||
- [ ] Display name must be set per account.
|
||||
- [ ] Remove the display name initials from the bottom-left corner.
|
||||
|
||||
+3
-1
@@ -3,7 +3,7 @@ async function openAccountManager(){
|
||||
try{
|
||||
const data=await window.daybreakMail.listAccounts();
|
||||
const accounts=data.accounts||[];
|
||||
const rows=accounts.map(account=>`<div class="account-row"><div class="account-row-info"><strong>${esc(account.email)}</strong><small>${esc(account.imapHost)} · ${esc(account.smtpHost)}</small></div><div class="account-row-actions">${account.id===data.activeId?'<span class="account-current">Current</span>':`<button class="outline-button" data-switch-account="${esc(account.id)}">Switch</button>`}<button class="discard" data-remove-account="${esc(account.id)}">Remove</button></div></div>`).join('');
|
||||
const rows=accounts.map(account=>`<div class="account-row"><div class="account-row-info"><strong>${esc(account.email)}</strong><small>${esc(account.imapHost)} · ${esc(account.smtpHost)}</small></div><div class="account-row-actions">${account.id===data.activeId?'<span class="account-current">Current</span>':`<button class="outline-button" data-switch-account="${esc(account.id)}">Switch</button>`}<button class="outline-button" data-edit-account="${esc(account.id)}">Edit</button><button class="discard" data-remove-account="${esc(account.id)}">Remove</button></div></div>`).join('');
|
||||
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Mail accounts</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields account-list">${rows||'<p class="account-note">No mailboxes connected yet.</p>'}</div><div class="compose-footer"><button class="discard modal-close">Close</button><button class="send-button" id="add-mail-account">+ Add account</button></div></div></div>`;
|
||||
const close=()=>root.innerHTML='';
|
||||
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
|
||||
@@ -12,6 +12,8 @@ async function openAccountManager(){
|
||||
root.onclick=async event=>{
|
||||
const switchButton=event.target.closest('[data-switch-account]');
|
||||
if(switchButton){switchButton.disabled=true;try{connectedMailAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);activeFolder='Inbox';mailPageOffset=0;document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));$('#sidebar-title').textContent='Inbox';$('#crumb-current').textContent='Inbox';updateAccountCard(connectedMailAccount);close();await syncMailbox(true,{offset:0})}catch(error){toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
|
||||
const editButton=event.target.closest('[data-edit-account]');
|
||||
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)openMailAccount(account);return}
|
||||
const removeButton=event.target.closest('[data-remove-account]');
|
||||
if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;connectedMailAccount=active;if(active){updateAccountCard(active);close();activeFolder='Inbox';mailPageOffset=0;await syncMailbox(false,{offset:0})}else{updateAccountCard({email:'Connect a mailbox',imapHost:''});messages.splice(0,messages.length);renderList();$('#reader-pane').innerHTML=emptyReader();toast('Mail account removed');openAccountManager()}}catch(error){toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
|
||||
};
|
||||
|
||||
+18
-1
@@ -274,6 +274,22 @@ ipcMain.handle('mail:remove-account', async (_event, accountId) => {
|
||||
return { accounts: store.accounts.map(publicAccount), activeId: store.activeId };
|
||||
});
|
||||
|
||||
ipcMain.handle('mail:update-account', async (_event, accountId, input) => {
|
||||
const store = await readAccountStore();
|
||||
const existing = store?.accounts.find(account => account.id === accountId);
|
||||
if (!existing) throw new Error('That mail account is no longer available.');
|
||||
const account = normalizeAccount({ ...existing, ...input, password: String(input?.password || '') || existing.password });
|
||||
account.id = existing.id;
|
||||
try {
|
||||
const status = await connectMail(account);
|
||||
store.accounts = store.accounts.map(item => item.id === existing.id ? account : item);
|
||||
await saveAccountStore(store);
|
||||
return { ...publicAccount(account), ...status };
|
||||
} catch (error) {
|
||||
throw new Error(`Could not update the mailbox: ${error.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('mail:connect', async (_event, input) => {
|
||||
const account = normalizeAccount(input);
|
||||
try {
|
||||
@@ -375,8 +391,9 @@ ipcMain.handle('mail:send', async (_event, message) => {
|
||||
if (!to) throw new Error('Add at least one recipient.');
|
||||
const transport = smtpTransport(account);
|
||||
const sentMessageId = `<${require('node:crypto').randomUUID()}@ep-mail.local>`;
|
||||
const fromName = String(message.displayName || account.email).replace(/[\r\n]+/g, ' ').trim().slice(0, 80) || account.email;
|
||||
const messageOptions = {
|
||||
from: { name: account.email, address: account.email },
|
||||
from: { name: fromName, address: account.email },
|
||||
to,
|
||||
cc: String(message.cc || '').trim() || undefined,
|
||||
subject: String(message.subject || '(no subject)').slice(0, 998),
|
||||
|
||||
@@ -6,6 +6,7 @@ contextBridge.exposeInMainWorld('daybreakMail', {
|
||||
selectAccount: id => ipcRenderer.invoke('mail:select-account', id),
|
||||
removeAccount: id => ipcRenderer.invoke('mail:remove-account', id),
|
||||
connect: details => ipcRenderer.invoke('mail:connect', details),
|
||||
updateAccount: (id, details) => ipcRenderer.invoke('mail:update-account', id, details),
|
||||
syncFolder: (folder, offset) => ipcRenderer.invoke('mail:sync-folder', folder, offset),
|
||||
syncInbox: () => ipcRenderer.invoke('mail:sync-folder', 'INBOX'),
|
||||
updateMessage: details => ipcRenderer.invoke('mail:update-message', details),
|
||||
|
||||
+32
-14
@@ -16,45 +16,62 @@ function updateAccountCard(account) {
|
||||
card.querySelector('.online-dot').style.background = '#70ad7b';
|
||||
}
|
||||
|
||||
function openMailAccount() {
|
||||
function openMailAccount(existingAccount = null) {
|
||||
const root = $('#modal-root');
|
||||
const current = {};
|
||||
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Add a mailbox</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Your password is encrypted with this computer’s credential storage. Connections require TLS.</p><label class="compose-line"><span>Email</span><input id="mail-account-email" type="email" autocomplete="username" value="" placeholder="name@example.com"></label><label class="compose-line"><span>Password</span><input id="mail-account-password" type="password" autocomplete="current-password" placeholder="Enter mailbox password"></label><label class="compose-line"><span>IMAP host</span><input id="mail-account-imap" value="" autocomplete="off" placeholder="imap.example.com"></label><label class="compose-line"><span>SMTP host</span><input id="mail-account-smtp" value="" autocomplete="off" placeholder="smtp.example.com"></label><p class="account-note">IMAP uses STARTTLS on port 143 · SMTP uses STARTTLS on port 587</p><p id="mail-account-status" class="account-status" aria-live="polite"></p></div><div class="compose-footer"><button class="discard" id="disconnect-mail">Cancel</button><button class="send-button" id="connect-mail">Test & connect</button></div></div></div>`;
|
||||
const editing = Boolean(existingAccount);
|
||||
const displayName = profileSettings.name || '';
|
||||
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${editing ? 'Edit mailbox' : 'Add a mailbox'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Your password is encrypted with this computer's credential storage. Connections require TLS.</p><label class="compose-line"><span>Email</span><input id="mail-account-email" type="email" autocomplete="username" value="${esc(existingAccount?.email || '')}" placeholder="name@example.com"></label><label class="compose-line"><span>Display name</span><input id="mail-account-display-name" maxlength="80" autocomplete="name" value="${esc(displayName)}" placeholder="Your name"></label><label class="compose-line"><span>Password</span><input id="mail-account-password" type="password" autocomplete="${editing ? 'new-password' : 'current-password'}" placeholder="${editing ? 'Leave blank to keep current password' : 'Enter mailbox password'}"></label><label class="compose-line"><span>IMAP host</span><input id="mail-account-imap" value="${esc(existingAccount?.imapHost || '')}" autocomplete="off" placeholder="imap.example.com"></label><label class="compose-line"><span>SMTP host</span><input id="mail-account-smtp" value="${esc(existingAccount?.smtpHost || '')}" autocomplete="off" placeholder="smtp.example.com"></label><p class="account-note">IMAP uses STARTTLS on port 143 · SMTP uses STARTTLS on port 587.${editing ? ' Leave the password empty to keep the saved password.' : ' Your display name is also used as the sender name.'}</p><p id="mail-account-status" class="account-status" aria-live="polite"></p></div><div class="compose-footer"><button class="discard" id="disconnect-mail">Cancel</button><button class="send-button" id="connect-mail">${editing ? 'Save & reconnect' : 'Test & connect'}</button></div></div></div>`;
|
||||
const close = () => { root.innerHTML = ''; };
|
||||
$$('.modal-close').forEach(button => button.onclick = close);
|
||||
$('.modal-overlay').addEventListener('click', event => { if (event.target.classList.contains('modal-overlay')) close(); });
|
||||
$('#disconnect-mail').onclick = async () => {
|
||||
close();
|
||||
};
|
||||
$('#disconnect-mail').onclick = close;
|
||||
$('#connect-mail').onclick = async () => {
|
||||
const button = $('#connect-mail');
|
||||
const status = $('#mail-account-status');
|
||||
const password = $('#mail-account-password').value;
|
||||
if (!password) { status.textContent = 'Enter the mailbox password to connect.'; $('#mail-account-password').focus(); return; }
|
||||
const name = $('#mail-account-display-name').value.trim();
|
||||
if (!editing && !password) { status.textContent = 'Enter the mailbox password to connect.'; $('#mail-account-password').focus(); return; }
|
||||
button.disabled = true;
|
||||
button.textContent = 'Checking secure connections…';
|
||||
status.textContent = 'Checking IMAP and SMTP sign-in. This may take a moment.';
|
||||
button.textContent = editing ? 'Checking updated settings…' : 'Checking secure connections…';
|
||||
status.textContent = editing ? 'Testing the updated mailbox settings before saving.' : 'Checking IMAP and SMTP sign-in. This may take a moment.';
|
||||
try {
|
||||
const account = await window.daybreakMail.connect({
|
||||
const details = {
|
||||
email: $('#mail-account-email').value,
|
||||
password,
|
||||
imapHost: $('#mail-account-imap').value,
|
||||
smtpHost: $('#mail-account-smtp').value
|
||||
});
|
||||
};
|
||||
const account = editing
|
||||
? await window.daybreakMail.updateAccount(existingAccount.id, details)
|
||||
: await window.daybreakMail.connect(details);
|
||||
if (name) setProfileName(name);
|
||||
if (editing) {
|
||||
const accountList = await window.daybreakMail.listAccounts();
|
||||
if (accountList.activeId === account.id) {
|
||||
connectedMailAccount = account;
|
||||
updateAccountCard(account);
|
||||
mailPageOffset = 0;
|
||||
close();
|
||||
await syncMailbox(false, { offset: 0 });
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
toast('Mailbox settings updated');
|
||||
} else {
|
||||
connectedMailAccount = account;
|
||||
updateAccountCard(account);
|
||||
close();
|
||||
toast('Mailbox connected securely');
|
||||
await syncMailbox(true);
|
||||
}
|
||||
} catch (error) {
|
||||
status.textContent = error.message || 'Could not connect. Check the account details and try again.';
|
||||
button.disabled = false;
|
||||
button.textContent = 'Test & connect';
|
||||
button.textContent = editing ? 'Save & reconnect' : 'Test & connect';
|
||||
}
|
||||
};
|
||||
$('#mail-account-email').focus();
|
||||
}
|
||||
|
||||
async function syncMailbox(showToast, options = {}) {
|
||||
if (!connectedMailAccount || !window.daybreakMail) {
|
||||
openMailAccount();
|
||||
@@ -138,7 +155,8 @@ if (window.daybreakMail) {
|
||||
to: recipient,
|
||||
cc: $('#compose-cc').value,
|
||||
subject: $('#compose-subject').value.trim(),
|
||||
text: $('#compose-body').value
|
||||
text: $('#compose-body').value,
|
||||
displayName: profileSettings.name
|
||||
});
|
||||
$('#modal-root').innerHTML = '';
|
||||
toast(result.savedToSent ? 'Message sent and saved in Sent' : 'Message sent, but its Sent copy could not be saved');
|
||||
|
||||
Reference in New Issue
Block a user