Refractoring Stage 6.11 The account manager now uses explicit mail and DAV feature APIs, is scoped locally instead of exposing a global helper, and loads after the DAV feature registers its API. Root and www/ assets are synchronized.
This commit is contained in:
+3
-1
@@ -111,6 +111,7 @@ This is a gradual destination, not a requirement to move everything at once. IPC
|
|||||||
- [x] Migrate OpenPGP key UI to the mail feature API for active-account access (`pgp-ui.js`).
|
- [x] Migrate OpenPGP key UI to the mail feature API for active-account access (`pgp-ui.js`).
|
||||||
- [x] Make the core app shell consume the namespaced renderer state instead of compatibility aliases.
|
- [x] Make the core app shell consume the namespaced renderer state instead of compatibility aliases.
|
||||||
- [x] Expose core shell behavior through an explicit renderer API and migrate mail UI selectors, notifications, rendering, and compose hooks to that API (`app.js`, `mail-ui.js`).
|
- [x] Expose core shell behavior through an explicit renderer API and migrate mail UI selectors, notifications, rendering, and compose hooks to that API (`app.js`, `mail-ui.js`).
|
||||||
|
- [x] Hide the account-manager script in a local module scope and route selectors, escaping, notifications, and DAV navigation through explicit feature APIs (`account-ui.js`, `dav-ui.js`).
|
||||||
- [x] Migrate additional mail-related consumers to unique local aliases to avoid classic-script lexical redeclarations.
|
- [x] Migrate additional mail-related consumers to unique local aliases to avoid classic-script lexical redeclarations.
|
||||||
- [x] Add a combined-script parse test to prevent duplicate top-level lexical declarations from stopping later UI scripts.
|
- [x] Add a combined-script parse test to prevent duplicate top-level lexical declarations from stopping later UI scripts.
|
||||||
- [ ] Migrate remaining mail-related consumers and remove transitional global dependencies.
|
- [ ] Migrate remaining mail-related consumers and remove transitional global dependencies.
|
||||||
@@ -139,7 +140,7 @@ This is a gradual destination, not a requirement to move everything at once. IPC
|
|||||||
- Electron Builder and the desktop Actions artifact name derive from `package.json`.
|
- Electron Builder and the desktop Actions artifact name derive from `package.json`.
|
||||||
- Android `versionName` derives from the same package version. Its current `versionCode` mapping is `major * 10000 + minor * 100 + patch`; keep minor and patch below 100, and revise the mapping before reaching that boundary to avoid collisions.
|
- Android `versionName` derives from the same package version. Its current `versionCode` mapping is `major * 10000 + minor * 100 + patch`; keep minor and patch below 100, and revise the mapping before reaching that boundary to avoid collisions.
|
||||||
- `scripts/build-all.ps1` uses the package version for APK naming. Before a release, bump once with `npm run bump:build`, verify the lockfile and computed Android version code, and build every target without another bump.
|
- `scripts/build-all.ps1` uses the package version for APK naming. Before a release, bump once with `npm run bump:build`, verify the lockfile and computed Android version code, and build every target without another bump.
|
||||||
- Latest version check: `package.json` and both lockfile version fields are `0.4.22`; Android derives `versionName 0.4.22` and `versionCode 422`. The user confirms the current artifact works.
|
- Latest version check: `package.json` and both lockfile version fields are `0.4.23`; Android derives `versionName 0.4.23` and `versionCode 423`. The user confirms the previous artifact works; this bump is for the next build.
|
||||||
|
|
||||||
## Progress log
|
## Progress log
|
||||||
|
|
||||||
@@ -164,5 +165,6 @@ This is a gradual destination, not a requirement to move everything at once. IPC
|
|||||||
- Step 6 migrated snooze, attachment, OpenPGP mail/key, shortcut, productivity state/render, and DAV UI integrations to feature APIs; compatibility globals remain in the core shell and some cross-feature hooks. The core app now reads shared state through `renderer-state.js`; the suite passes 123 tests.
|
- Step 6 migrated snooze, attachment, OpenPGP mail/key, shortcut, productivity state/render, and DAV UI integrations to feature APIs; compatibility globals remain in the core shell and some cross-feature hooks. The core app now reads shared state through `renderer-state.js`; the suite passes 123 tests.
|
||||||
- Step 6 added an explicit `epMailShell` interface for mail UI selectors, notifications, views, and renderer wrappers. `mail-ui.js` now uses it rather than directly replacing core renderer functions; search resets use namespaced state, and preferences remain owned by the productivity feature.
|
- Step 6 added an explicit `epMailShell` interface for mail UI selectors, notifications, views, and renderer wrappers. `mail-ui.js` now uses it rather than directly replacing core renderer functions; search resets use namespaced state, and preferences remain owned by the productivity feature.
|
||||||
- Step 6 verification at version `0.4.22` / Android build number `422`: all 123 tests pass, including generated `www/` parity and combined classic-script parsing.
|
- Step 6 verification at version `0.4.22` / Android build number `422`: all 123 tests pass, including generated `www/` parity and combined classic-script parsing.
|
||||||
|
- Step 6 at version `0.4.23` moves account-manager dependencies onto feature APIs and publishes the DAV manager through `window.epMailFeatures.dav` instead of a free global function.
|
||||||
- The current IPC/DAV validation changes pass the full suite: 108 tests.
|
- The current IPC/DAV validation changes pass the full suite: 108 tests.
|
||||||
- While work continued, `package.json` and `package-lock.json` reflected a version bump to `0.4.6`; those changes were preserved.
|
- While work continued, `package.json` and `package-lock.json` reflected a version bump to `0.4.6`; those changes were preserved.
|
||||||
|
|||||||
+9
-6
@@ -1,11 +1,13 @@
|
|||||||
|
(() => {
|
||||||
const accountMailUi = window.epMailFeatures.mail;
|
const accountMailUi = window.epMailFeatures.mail;
|
||||||
|
const accountDavUi = window.epMailFeatures.dav;
|
||||||
|
|
||||||
async function openAccountManager(){
|
async function openAccountManager(){
|
||||||
const root=$('#modal-root');
|
const root=accountMailUi.select('#modal-root');
|
||||||
try{
|
try{
|
||||||
const data=await window.daybreakMail.listAccounts();
|
const data=await window.daybreakMail.listAccounts();
|
||||||
const accounts=data.accounts||[];
|
const accounts=data.accounts||[];
|
||||||
const rows=accounts.map(account=>`<div class="account-row"><div class="account-row-info"><strong>${esc(account.displayName||account.email)}</strong><small>${esc(account.email)} · ${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('');
|
const rows=accounts.map(account=>`<div class="account-row"><div class="account-row-info"><strong>${accountMailUi.escapeHtml(account.displayName||account.email)}</strong><small>${accountMailUi.escapeHtml(account.email)} · ${accountMailUi.escapeHtml(account.imapHost)} · ${accountMailUi.escapeHtml(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="${accountMailUi.escapeHtml(account.id)}">Switch</button>`}<button class="outline-button" data-edit-account="${accountMailUi.escapeHtml(account.id)}">Edit</button><button class="discard" data-remove-account="${accountMailUi.escapeHtml(account.id)}">Remove</button></div></div>`).join('');
|
||||||
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Account Settings</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 class="account-row"><div class="account-row-info"><strong>Calendar and contacts</strong><small>Configure CalDAV calendar and CardDAV address book servers.</small></div><div class="account-row-actions"><button class="outline-button" data-open-dav="caldav">Calendar servers</button><button class="outline-button" data-open-dav="carddav">Contact servers</button></div></div></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>`;
|
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Account Settings</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 class="account-row"><div class="account-row-info"><strong>Calendar and contacts</strong><small>Configure CalDAV calendar and CardDAV address book servers.</small></div><div class="account-row-actions"><button class="outline-button" data-open-dav="caldav">Calendar servers</button><button class="outline-button" data-open-dav="carddav">Contact servers</button></div></div></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='';
|
const close=()=>root.innerHTML='';
|
||||||
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
|
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
|
||||||
@@ -13,16 +15,17 @@ async function openAccountManager(){
|
|||||||
root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()};
|
root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()};
|
||||||
root.onclick=async event=>{
|
root.onclick=async event=>{
|
||||||
const switchButton=event.target.closest('[data-switch-account]');
|
const switchButton=event.target.closest('[data-switch-account]');
|
||||||
if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));$('#sidebar-title').textContent='Inbox';$('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
|
if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));accountMailUi.select('#sidebar-title').textContent='Inbox';accountMailUi.select('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){accountMailUi.toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
|
||||||
const davButton=event.target.closest('[data-open-dav]');
|
const davButton=event.target.closest('[data-open-dav]');
|
||||||
if(davButton){close();openDavManager(davButton.dataset.openDav);return}
|
if(davButton){close();accountDavUi.openManager(davButton.dataset.openDav);return}
|
||||||
const editButton=event.target.closest('[data-edit-account]');
|
const editButton=event.target.closest('[data-edit-account]');
|
||||||
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return}
|
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return}
|
||||||
const removeButton=event.target.closest('[data-remove-account]');
|
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;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();$('#reader-pane').innerHTML=accountMailUi.emptyReader();toast('Mail account removed');openAccountManager()}}catch(error){toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
|
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;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();accountMailUi.select('#reader-pane').innerHTML=accountMailUi.emptyReader();accountMailUi.toast('Mail account removed');openAccountManager()}}catch(error){accountMailUi.toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
|
||||||
};
|
};
|
||||||
}catch(error){toast(error.message||'Could not load mail accounts')}
|
}catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
||||||
document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
||||||
|
})();
|
||||||
|
|||||||
@@ -40,3 +40,8 @@ function showDavConnect(type){
|
|||||||
root.querySelector('#dav-server-url').focus();
|
root.querySelector('#dav-server-url').focus();
|
||||||
}
|
}
|
||||||
document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true);
|
document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true);
|
||||||
|
|
||||||
|
window.epMailFeatures.dav = Object.freeze({
|
||||||
|
openManager: openDavManager,
|
||||||
|
sync: syncDav
|
||||||
|
});
|
||||||
|
|||||||
+1
-1
@@ -72,8 +72,8 @@
|
|||||||
<script src="mail-ui.js"></script>
|
<script src="mail-ui.js"></script>
|
||||||
<script src="productivity.js"></script>
|
<script src="productivity.js"></script>
|
||||||
<script src="snooze-ui.js"></script>
|
<script src="snooze-ui.js"></script>
|
||||||
<script src="account-ui.js"></script>
|
|
||||||
<script src="dav-ui.js"></script>
|
<script src="dav-ui.js"></script>
|
||||||
|
<script src="account-ui.js"></script>
|
||||||
<script src="shortcuts.js"></script>
|
<script src="shortcuts.js"></script>
|
||||||
<script src="attachments.js"></script>
|
<script src="attachments.js"></script>
|
||||||
<script src="pgp-ui.js"></script>
|
<script src="pgp-ui.js"></script>
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.4.22",
|
"version": "0.4.23",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.4.22",
|
"version": "0.4.23",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.5.2",
|
"@capacitor/android": "^8.5.2",
|
||||||
"@capacitor/core": "^8.5.2",
|
"@capacitor/core": "^8.5.2",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.4.22",
|
"version": "0.4.23",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Eternity Project mail client",
|
"description": "Eternity Project mail client",
|
||||||
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ test('renderer bootstrap loads shared state and mail security before the applica
|
|||||||
const app = html.indexOf('<script src="app.js"></script>');
|
const app = html.indexOf('<script src="app.js"></script>');
|
||||||
const platformBridge = html.indexOf('<script src="platform-bridge.js"></script>');
|
const platformBridge = html.indexOf('<script src="platform-bridge.js"></script>');
|
||||||
const mailUi = html.indexOf('<script src="mail-ui.js"></script>');
|
const mailUi = html.indexOf('<script src="mail-ui.js"></script>');
|
||||||
|
const productivity = html.indexOf('<script src="productivity.js"></script>');
|
||||||
|
const davUi = html.indexOf('<script src="dav-ui.js"></script>');
|
||||||
|
const accountUi = html.indexOf('<script src="account-ui.js"></script>');
|
||||||
assert.ok(state >= 0 && contentSecurity > state && app > contentSecurity && mailApi > platformBridge && mailUi > mailApi);
|
assert.ok(state >= 0 && contentSecurity > state && app > contentSecurity && mailApi > platformBridge && mailUi > mailApi);
|
||||||
|
assert.ok(productivity > mailUi && davUi > productivity && accountUi > davUi);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('core app shell uses the namespaced renderer state', () => {
|
test('core app shell uses the namespaced renderer state', () => {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ test('account and snooze UI consume the explicit mail API instead of selected le
|
|||||||
const attachmentUi = fs.readFileSync(path.join(root, 'attachments.js'), 'utf8');
|
const attachmentUi = fs.readFileSync(path.join(root, 'attachments.js'), 'utf8');
|
||||||
const pgpMailUi = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
|
const pgpMailUi = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
|
||||||
const pgpUi = fs.readFileSync(path.join(root, 'pgp-ui.js'), 'utf8');
|
const pgpUi = fs.readFileSync(path.join(root, 'pgp-ui.js'), 'utf8');
|
||||||
|
const davUi = fs.readFileSync(path.join(root, 'dav-ui.js'), 'utf8');
|
||||||
const appShell = fs.readFileSync(path.join(root, 'app.js'), 'utf8');
|
const appShell = fs.readFileSync(path.join(root, 'app.js'), 'utf8');
|
||||||
const mailUi = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
|
const mailUi = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
|
||||||
const shortcutsUi = fs.readFileSync(path.join(root, 'shortcuts.js'), 'utf8');
|
const shortcutsUi = fs.readFileSync(path.join(root, 'shortcuts.js'), 'utf8');
|
||||||
@@ -72,6 +73,10 @@ test('account and snooze UI consume the explicit mail API instead of selected le
|
|||||||
assert.match(attachmentUi, /window\.epMailFeatures\.mail/);
|
assert.match(attachmentUi, /window\.epMailFeatures\.mail/);
|
||||||
assert.match(pgpMailUi, /window\.epMailFeatures\.mail/);
|
assert.match(pgpMailUi, /window\.epMailFeatures\.mail/);
|
||||||
assert.match(pgpUi, /window\.epMailFeatures\.mail\.connectedAccount/);
|
assert.match(pgpUi, /window\.epMailFeatures\.mail\.connectedAccount/);
|
||||||
|
assert.match(accountUi, /const accountDavUi = window\.epMailFeatures\.dav/);
|
||||||
|
assert.match(accountUi, /accountDavUi\.openManager/);
|
||||||
|
assert.doesNotMatch(accountUi, /(?<!\.)\b(?:esc|toast)\s*\(|(?<!\.)\$\(/);
|
||||||
|
assert.match(davUi, /window\.epMailFeatures\.dav = Object\.freeze/);
|
||||||
assert.match(appShell, /window\.epMailShell = Object\.freeze/);
|
assert.match(appShell, /window\.epMailShell = Object\.freeze/);
|
||||||
assert.match(mailUi, /appShell\.wrapOpenMessage/);
|
assert.match(mailUi, /appShell\.wrapOpenMessage/);
|
||||||
assert.match(mailUi, /appShell\.wrapShowCompose/);
|
assert.match(mailUi, /appShell\.wrapShowCompose/);
|
||||||
|
|||||||
+9
-6
@@ -1,11 +1,13 @@
|
|||||||
|
(() => {
|
||||||
const accountMailUi = window.epMailFeatures.mail;
|
const accountMailUi = window.epMailFeatures.mail;
|
||||||
|
const accountDavUi = window.epMailFeatures.dav;
|
||||||
|
|
||||||
async function openAccountManager(){
|
async function openAccountManager(){
|
||||||
const root=$('#modal-root');
|
const root=accountMailUi.select('#modal-root');
|
||||||
try{
|
try{
|
||||||
const data=await window.daybreakMail.listAccounts();
|
const data=await window.daybreakMail.listAccounts();
|
||||||
const accounts=data.accounts||[];
|
const accounts=data.accounts||[];
|
||||||
const rows=accounts.map(account=>`<div class="account-row"><div class="account-row-info"><strong>${esc(account.displayName||account.email)}</strong><small>${esc(account.email)} · ${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('');
|
const rows=accounts.map(account=>`<div class="account-row"><div class="account-row-info"><strong>${accountMailUi.escapeHtml(account.displayName||account.email)}</strong><small>${accountMailUi.escapeHtml(account.email)} · ${accountMailUi.escapeHtml(account.imapHost)} · ${accountMailUi.escapeHtml(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="${accountMailUi.escapeHtml(account.id)}">Switch</button>`}<button class="outline-button" data-edit-account="${accountMailUi.escapeHtml(account.id)}">Edit</button><button class="discard" data-remove-account="${accountMailUi.escapeHtml(account.id)}">Remove</button></div></div>`).join('');
|
||||||
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Account Settings</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 class="account-row"><div class="account-row-info"><strong>Calendar and contacts</strong><small>Configure CalDAV calendar and CardDAV address book servers.</small></div><div class="account-row-actions"><button class="outline-button" data-open-dav="caldav">Calendar servers</button><button class="outline-button" data-open-dav="carddav">Contact servers</button></div></div></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>`;
|
root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Account Settings</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 class="account-row"><div class="account-row-info"><strong>Calendar and contacts</strong><small>Configure CalDAV calendar and CardDAV address book servers.</small></div><div class="account-row-actions"><button class="outline-button" data-open-dav="caldav">Calendar servers</button><button class="outline-button" data-open-dav="carddav">Contact servers</button></div></div></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='';
|
const close=()=>root.innerHTML='';
|
||||||
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
|
root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);
|
||||||
@@ -13,16 +15,17 @@ async function openAccountManager(){
|
|||||||
root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()};
|
root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()};
|
||||||
root.onclick=async event=>{
|
root.onclick=async event=>{
|
||||||
const switchButton=event.target.closest('[data-switch-account]');
|
const switchButton=event.target.closest('[data-switch-account]');
|
||||||
if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));$('#sidebar-title').textContent='Inbox';$('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
|
if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));accountMailUi.select('#sidebar-title').textContent='Inbox';accountMailUi.select('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){accountMailUi.toast(error.message||'Could not switch accounts');switchButton.disabled=false}return}
|
||||||
const davButton=event.target.closest('[data-open-dav]');
|
const davButton=event.target.closest('[data-open-dav]');
|
||||||
if(davButton){close();openDavManager(davButton.dataset.openDav);return}
|
if(davButton){close();accountDavUi.openManager(davButton.dataset.openDav);return}
|
||||||
const editButton=event.target.closest('[data-edit-account]');
|
const editButton=event.target.closest('[data-edit-account]');
|
||||||
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return}
|
if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return}
|
||||||
const removeButton=event.target.closest('[data-remove-account]');
|
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;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();$('#reader-pane').innerHTML=accountMailUi.emptyReader();toast('Mail account removed');openAccountManager()}}catch(error){toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
|
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;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();accountMailUi.select('#reader-pane').innerHTML=accountMailUi.emptyReader();accountMailUi.toast('Mail account removed');openAccountManager()}}catch(error){accountMailUi.toast(error.message||'Could not remove the account');removeButton.disabled=false}return}
|
||||||
};
|
};
|
||||||
}catch(error){toast(error.message||'Could not load mail accounts')}
|
}catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
||||||
document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true);
|
||||||
|
})();
|
||||||
|
|||||||
@@ -40,3 +40,8 @@ function showDavConnect(type){
|
|||||||
root.querySelector('#dav-server-url').focus();
|
root.querySelector('#dav-server-url').focus();
|
||||||
}
|
}
|
||||||
document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true);
|
document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true);
|
||||||
|
|
||||||
|
window.epMailFeatures.dav = Object.freeze({
|
||||||
|
openManager: openDavManager,
|
||||||
|
sync: syncDav
|
||||||
|
});
|
||||||
|
|||||||
+1
-1
@@ -72,8 +72,8 @@
|
|||||||
<script src="mail-ui.js"></script>
|
<script src="mail-ui.js"></script>
|
||||||
<script src="productivity.js"></script>
|
<script src="productivity.js"></script>
|
||||||
<script src="snooze-ui.js"></script>
|
<script src="snooze-ui.js"></script>
|
||||||
<script src="account-ui.js"></script>
|
|
||||||
<script src="dav-ui.js"></script>
|
<script src="dav-ui.js"></script>
|
||||||
|
<script src="account-ui.js"></script>
|
||||||
<script src="shortcuts.js"></script>
|
<script src="shortcuts.js"></script>
|
||||||
<script src="attachments.js"></script>
|
<script src="attachments.js"></script>
|
||||||
<script src="pgp-ui.js"></script>
|
<script src="pgp-ui.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user