Ver V0.1.14 Add automatic ui refresh
This commit is contained in:
@@ -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
@@ -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,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),
|
||||||
|
|||||||
+78
-34
@@ -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,61 +76,102 @@ 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;
|
||||||
try {
|
const sync = (async () => {
|
||||||
const offset = options.offset ?? (options.append ? mailPageOffset + messages.length : mailPageOffset);
|
try {
|
||||||
const result = await window.daybreakMail.syncFolder(activeFolder, offset);
|
const previouslyActiveMessage = activeMessage;
|
||||||
if (options.append) messages.push(...result.messages);
|
const offset = options.offset ?? (options.append ? mailPageOffset + messages.length : mailPageOffset);
|
||||||
else messages.splice(0, messages.length, ...result.messages);
|
const result = await window.daybreakMail.syncFolder(activeFolder, offset);
|
||||||
messages.forEach(message => {
|
if (options.append) messages.push(...result.messages);
|
||||||
try {
|
else messages.splice(0, messages.length, ...result.messages);
|
||||||
const localTags = JSON.parse(localStorage.getItem(`daybreak-message-labels-${message.id}`) || '[]');
|
messages.forEach(message => {
|
||||||
message.tags = [...new Set([...(message.tags || []), ...localTags])];
|
try {
|
||||||
} catch {}
|
const localTags = JSON.parse(localStorage.getItem(`daybreak-message-labels-${message.id}`) || '[]');
|
||||||
});
|
message.tags = [...new Set([...(message.tags || []), ...localTags])];
|
||||||
if (!options.append) mailPageOffset = offset;
|
} catch {}
|
||||||
mailTotal = result.total;
|
});
|
||||||
activeMessage = messages[0]?.id;
|
if (!options.append) mailPageOffset = offset;
|
||||||
selectedIds.clear();
|
mailTotal = result.total;
|
||||||
const unread = messages.filter(message => message.unread).length;
|
activeMessage = messages.some(message => message.id === previouslyActiveMessage)
|
||||||
const inboxCount = $('.folder[data-folder="Inbox"] .count');
|
? previouslyActiveMessage
|
||||||
if (inboxCount) inboxCount.textContent = String(unread);
|
: messages[0]?.id;
|
||||||
const pagination = $('#pagination');
|
selectedIds.clear();
|
||||||
if (pagination) pagination.textContent = result.total ? `${options.append ? 1 : result.start}–${options.append ? Math.min(offset + result.messages.length, result.total) : result.end} of ${result.total}` : '0 messages';
|
const unread = messages.filter(message => message.unread).length;
|
||||||
const loadMore = $('#load-more');
|
const inboxCount = $('.folder[data-folder="Inbox"] .count');
|
||||||
if (loadMore) loadMore.classList.toggle('hidden', mailPageOffset + messages.length >= result.total);
|
if (inboxCount) inboxCount.textContent = String(unread);
|
||||||
renderList();
|
const pagination = $('#pagination');
|
||||||
if (activeMessage) {
|
if (pagination) pagination.textContent = result.total ? `${options.append ? 1 : result.start}–${options.append ? Math.min(offset + result.messages.length, result.total) : result.end} of ${result.total}` : '0 messages';
|
||||||
openMessage(activeMessage);
|
const loadMore = $('#load-more');
|
||||||
const current = messages.find(message => message.id === activeMessage);
|
if (loadMore) loadMore.classList.toggle('hidden', mailPageOffset + messages.length >= result.total);
|
||||||
if (current?.uid) window.daybreakMail.updateMessage({ uid: current.uid, folder: activeFolder, action: 'unread', enabled: false }).catch(() => {});
|
renderList();
|
||||||
|
if (activeMessage) {
|
||||||
|
openMessage(activeMessage);
|
||||||
|
const current = messages.find(message => message.id === activeMessage);
|
||||||
|
if (current?.uid) window.daybreakMail.updateMessage({ uid: current.uid, folder: activeFolder, action: 'unread', enabled: false }).catch(() => {});
|
||||||
|
}
|
||||||
|
else $('#reader-pane').innerHTML = emptyReader();
|
||||||
|
updateAccountCard(connectedMailAccount);
|
||||||
|
if (showToast) toast(`Synced ${messages.length} messages`);
|
||||||
|
} catch (error) {
|
||||||
|
toast(error.message || 'Could not sync the inbox');
|
||||||
|
} finally {
|
||||||
|
if (refresh) refresh.disabled = false;
|
||||||
}
|
}
|
||||||
else $('#reader-pane').innerHTML = emptyReader();
|
})();
|
||||||
updateAccountCard(connectedMailAccount);
|
mailboxSyncPromise = sync;
|
||||||
if (showToast) toast(`Synced ${messages.length} messages`);
|
try {
|
||||||
} catch (error) {
|
await sync;
|
||||||
toast(error.message || 'Could not sync the inbox');
|
|
||||||
} finally {
|
} finally {
|
||||||
if (refresh) refresh.disabled = false;
|
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(); }
|
||||||
|
|||||||
Generated
+2
-2
@@ -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
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user