Ver V0.1.14 Add automatic ui refresh

This commit is contained in:
2026-10-06 23:40:11 +03:00
parent e50073ab4c
commit 2becdcccd7
6 changed files with 88 additions and 38 deletions
+3
View File
@@ -4,6 +4,7 @@
- [x] Rename the program to **ep-mail** across the app UI, package metadata, desktop builds, and documentation. - [x] Rename the program to **ep-mail** across the app UI, package metadata, desktop builds, and documentation.
- [x] Replace the temporary sun/asterisk app mark with the Git and webmail logo, using the EP Daylight and EP Wasteland color variants. - [x] Replace the temporary sun/asterisk app mark with the Git and webmail logo, using the EP Daylight and EP Wasteland color variants.
- [x] Show the app version after **ep-mail** in the window title.
## Mail security ## Mail security
@@ -18,6 +19,8 @@
## Account settings ## Account settings
- [ ] Fix the mailbox space indicator; it is not working.
- [x] Fix automatic mail sync so the message list refreshes when new mail arrives.
- [x] Sync all connected accounts' mailboxes in the Electron main process at launch/resume and periodically in the background. - [x] Sync all connected accounts' mailboxes in the Electron main process at launch/resume and periodically in the background.
- [x] Track `UIDVALIDITY`, the last processed UID, and `HIGHESTMODSEQ` per account and folder; fall back to checking message flags when mod-sequences are unavailable. - [x] Track `UIDVALIDITY`, the last processed UID, and `HIGHESTMODSEQ` per account and folder; fall back to checking message flags when mod-sequences are unavailable.
- [ ] Add persistent IMAP IDLE watchers; bounded periodic polling currently provides updates and reconnect/backoff. - [ ] Add persistent IMAP IDLE watchers; bounded periodic polling currently provides updates and reconnect/backoff.
+3 -1
View File
@@ -444,6 +444,8 @@ async function runBackgroundSync() {
} }
} }
ipcMain.handle('app:get-version', () => app.getVersion());
ipcMain.handle('mail:get-account', async () => { ipcMain.handle('mail:get-account', async () => {
const account = await readAccount(); const account = await readAccount();
return account ? publicAccount(account) : null; return account ? publicAccount(account) : null;
@@ -813,7 +815,7 @@ function createWindow() {
height: 920, height: 920,
minWidth: 920, minWidth: 920,
minHeight: 680, minHeight: 680,
title: 'ep-mail', title: `ep-mail v${app.getVersion()}`,
backgroundColor: '#f4f5f1', backgroundColor: '#f4f5f1',
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
+1
View File
@@ -1,6 +1,7 @@
const { contextBridge, ipcRenderer } = require('electron'); const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('daybreakMail', { contextBridge.exposeInMainWorld('daybreakMail', {
getAppVersion: () => ipcRenderer.invoke('app:get-version'),
getAccount: () => ipcRenderer.invoke('mail:get-account'), getAccount: () => ipcRenderer.invoke('mail:get-account'),
listAccounts: () => ipcRenderer.invoke('mail:list-accounts'), listAccounts: () => ipcRenderer.invoke('mail:list-accounts'),
selectAccount: id => ipcRenderer.invoke('mail:select-account', id), selectAccount: id => ipcRenderer.invoke('mail:select-account', id),
+46 -2
View File
@@ -1,6 +1,9 @@
let connectedMailAccount = null; let connectedMailAccount = null;
let mailPageOffset = 0; let mailPageOffset = 0;
let mailTotal = 0; let mailTotal = 0;
let mailboxSyncPromise = null;
let mailboxSyncQueued = false;
let mailboxRefreshPending = false;
function updateAccountCard(account) { function updateAccountCard(account) {
const card = $('#account-settings'); const card = $('#account-settings');
@@ -73,13 +76,19 @@ function openMailAccount(existingAccount = null) {
$('#mail-account-email').focus(); $('#mail-account-email').focus();
} }
async function syncMailbox(showToast, options = {}) { async function syncMailbox(showToast, options = {}) {
if (mailboxSyncPromise) {
mailboxSyncQueued = true;
return mailboxSyncPromise;
}
if (!connectedMailAccount || !window.daybreakMail) { if (!connectedMailAccount || !window.daybreakMail) {
openMailAccount(); openMailAccount();
return; return;
} }
const refresh = $('#refresh'); const refresh = $('#refresh');
if (refresh) refresh.disabled = true; if (refresh) refresh.disabled = true;
const sync = (async () => {
try { try {
const previouslyActiveMessage = activeMessage;
const offset = options.offset ?? (options.append ? mailPageOffset + messages.length : mailPageOffset); const offset = options.offset ?? (options.append ? mailPageOffset + messages.length : mailPageOffset);
const result = await window.daybreakMail.syncFolder(activeFolder, offset); const result = await window.daybreakMail.syncFolder(activeFolder, offset);
if (options.append) messages.push(...result.messages); if (options.append) messages.push(...result.messages);
@@ -92,7 +101,9 @@ async function syncMailbox(showToast, options = {}) {
}); });
if (!options.append) mailPageOffset = offset; if (!options.append) mailPageOffset = offset;
mailTotal = result.total; mailTotal = result.total;
activeMessage = messages[0]?.id; activeMessage = messages.some(message => message.id === previouslyActiveMessage)
? previouslyActiveMessage
: messages[0]?.id;
selectedIds.clear(); selectedIds.clear();
const unread = messages.filter(message => message.unread).length; const unread = messages.filter(message => message.unread).length;
const inboxCount = $('.folder[data-folder="Inbox"] .count'); const inboxCount = $('.folder[data-folder="Inbox"] .count');
@@ -115,19 +126,52 @@ async function syncMailbox(showToast, options = {}) {
} finally { } finally {
if (refresh) refresh.disabled = false; if (refresh) refresh.disabled = false;
} }
})();
mailboxSyncPromise = sync;
try {
await sync;
} finally {
mailboxSyncPromise = null;
if (mailboxSyncQueued) {
mailboxSyncQueued = false;
void syncMailbox(false);
}
}
} }
if (window.daybreakMail) { if (window.daybreakMail) {
window.daybreakMail.getAppVersion().then(version => {
document.title = `ep-mail v${version}`;
}).catch(error => {
console.error('Could not read app version:', error);
});
window.daybreakMail.onSyncUpdate(update => { window.daybreakMail.onSyncUpdate(update => {
if (update.accountId !== connectedMailAccount?.id) return; if (update.accountId !== connectedMailAccount?.id) return;
if (update.error) { if (update.error) {
toast(update.error); toast(update.error);
return; return;
} }
if ((update.foldersChanged || []).includes(activeFolder)) { if (update.newCount || (update.foldersChanged || []).length) {
if (document.visibilityState === 'visible') {
syncMailbox(false, update.newCount ? { offset: 0 } : {});
}
else mailboxRefreshPending = true;
}
});
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible' && mailboxRefreshPending) {
mailboxRefreshPending = false;
syncMailbox(false, { offset: 0 }); syncMailbox(false, { offset: 0 });
} }
}); });
window.addEventListener('focus', () => {
if (connectedMailAccount) syncMailbox(false);
});
setInterval(() => {
if (connectedMailAccount && document.visibilityState === 'visible' && activeView === 'mail') {
syncMailbox(false);
}
}, 60 * 1000);
$('#account-settings').addEventListener('click', openMailAccount); $('#account-settings').addEventListener('click', openMailAccount);
$('#account-settings').addEventListener('keydown', event => { $('#account-settings').addEventListener('keydown', event => {
if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); } if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); }
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "ep-mail", "name": "ep-mail",
"version": "0.1.13", "version": "0.1.14",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "ep-mail", "name": "ep-mail",
"version": "0.1.13", "version": "0.1.14",
"dependencies": { "dependencies": {
"ical.js": "^2.2.1", "ical.js": "^2.2.1",
"imapflow": "2.2.1", "imapflow": "2.2.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "ep-mail", "name": "ep-mail",
"version": "0.1.13", "version": "0.1.14",
"private": true, "private": true,
"description": "Eternity Project mail client", "description": "Eternity Project mail client",
"author": "Eternity Project", "author": "Eternity Project",