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] 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
@@ -18,6 +19,8 @@
## 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] 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.
+3 -1
View File
@@ -444,6 +444,8 @@ async function runBackgroundSync() {
}
}
ipcMain.handle('app:get-version', () => app.getVersion());
ipcMain.handle('mail:get-account', async () => {
const account = await readAccount();
return account ? publicAccount(account) : null;
@@ -813,7 +815,7 @@ function createWindow() {
height: 920,
minWidth: 920,
minHeight: 680,
title: 'ep-mail',
title: `ep-mail v${app.getVersion()}`,
backgroundColor: '#f4f5f1',
show: false,
autoHideMenuBar: true,
+1
View File
@@ -1,6 +1,7 @@
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('daybreakMail', {
getAppVersion: () => ipcRenderer.invoke('app:get-version'),
getAccount: () => ipcRenderer.invoke('mail:get-account'),
listAccounts: () => ipcRenderer.invoke('mail:list-accounts'),
selectAccount: id => ipcRenderer.invoke('mail:select-account', id),
+46 -2
View File
@@ -1,6 +1,9 @@
let connectedMailAccount = null;
let mailPageOffset = 0;
let mailTotal = 0;
let mailboxSyncPromise = null;
let mailboxSyncQueued = false;
let mailboxRefreshPending = false;
function updateAccountCard(account) {
const card = $('#account-settings');
@@ -73,13 +76,19 @@ function openMailAccount(existingAccount = null) {
$('#mail-account-email').focus();
}
async function syncMailbox(showToast, options = {}) {
if (mailboxSyncPromise) {
mailboxSyncQueued = true;
return mailboxSyncPromise;
}
if (!connectedMailAccount || !window.daybreakMail) {
openMailAccount();
return;
}
const refresh = $('#refresh');
if (refresh) refresh.disabled = true;
const sync = (async () => {
try {
const previouslyActiveMessage = activeMessage;
const offset = options.offset ?? (options.append ? mailPageOffset + messages.length : mailPageOffset);
const result = await window.daybreakMail.syncFolder(activeFolder, offset);
if (options.append) messages.push(...result.messages);
@@ -92,7 +101,9 @@ async function syncMailbox(showToast, options = {}) {
});
if (!options.append) mailPageOffset = offset;
mailTotal = result.total;
activeMessage = messages[0]?.id;
activeMessage = messages.some(message => message.id === previouslyActiveMessage)
? previouslyActiveMessage
: messages[0]?.id;
selectedIds.clear();
const unread = messages.filter(message => message.unread).length;
const inboxCount = $('.folder[data-folder="Inbox"] .count');
@@ -115,19 +126,52 @@ async function syncMailbox(showToast, options = {}) {
} finally {
if (refresh) refresh.disabled = false;
}
})();
mailboxSyncPromise = sync;
try {
await sync;
} finally {
mailboxSyncPromise = null;
if (mailboxSyncQueued) {
mailboxSyncQueued = false;
void syncMailbox(false);
}
}
}
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 => {
if (update.accountId !== connectedMailAccount?.id) return;
if (update.error) {
toast(update.error);
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 });
}
});
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('keydown', event => {
if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); }
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "ep-mail",
"version": "0.1.13",
"version": "0.1.14",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ep-mail",
"version": "0.1.13",
"version": "0.1.14",
"dependencies": {
"ical.js": "^2.2.1",
"imapflow": "2.2.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ep-mail",
"version": "0.1.13",
"version": "0.1.14",
"private": true,
"description": "Eternity Project mail client",
"author": "Eternity Project",