Add creating IMAP folders from the app

Bump version to 0.2.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-10-07 10:03:15 +03:00
co-authored by Copilot
parent 47ec7bdb80
commit 43be32b162
17 changed files with 271 additions and 9 deletions
+2
View File
@@ -33,6 +33,8 @@
<button class="folder" data-folder="Archive"><span class="nav-glyph">▱</span><span>Archive</span></button>
<button class="folder" data-folder="Trash"><span class="nav-glyph">⌫</span><span>Trash</span></button>
</nav>
<div class="section-label"><span>FOLDERS</span><button class="folder-add" id="add-folder" aria-label="Create folder">+</button></div>
<div id="custom-folders" class="folder-nav"></div>
<div class="sidebar-divider"></div>
<div class="section-label"><span>LABELS</span><button class="tiny-plus" id="add-label" aria-label="Add label">+</button></div>
<button class="label-link" data-label="Design"><i class="label-dot dot-amber"></i>Design</button>
+54
View File
@@ -102,6 +102,58 @@ openMessage = function (id) {
}
};
let customFolders = [];
function renderCustomFolders() {
const box = $('#custom-folders');
if (!box) return;
box.replaceChildren(...customFolders.map(folder => {
const button = document.createElement('button');
button.className = 'folder custom-folder';
button.dataset.folder = folder.id;
button.classList.toggle('active', activeFolder === folder.id);
const glyph = document.createElement('span');
glyph.className = 'nav-glyph';
glyph.textContent = '▭';
const label = document.createElement('span');
label.textContent = folder.name;
button.title = folder.path;
button.append(glyph, label);
button.addEventListener('click', () => {
if ($('#filter-folder').value) { $('#filter-folder').value = ''; folderBeforeSearch = null; }
activeFolder = folder.id;
$$('.folder').forEach(item => item.classList.toggle('active', item === button));
$('#sidebar-title').textContent = folder.name;
$('#crumb-current').textContent = folder.name;
mailPageOffset = 0;
void syncMailbox(false, { offset: 0 });
});
return button;
}));
}
async function loadCustomFolders() {
if (!connectedMailAccount || !window.daybreakMail?.listFolders) return;
try {
customFolders = (await window.daybreakMail.listFolders()).folders || [];
renderCustomFolders();
} catch {}
}
async function createMailFolder() {
if (!connectedMailAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; }
const name = prompt('New mail folder name:')?.trim();
if (!name) return;
try {
const result = await window.daybreakMail.createFolder(name);
customFolders = result.folders || customFolders;
renderCustomFolders();
toast(`Folder “${result.folder?.name || name}” created`);
} catch (error) {
toast(error.message || 'Could not create the folder');
}
}
function updateAccountCard(account) {
const card = $('#account-settings');
if (!card) return;
@@ -114,6 +166,7 @@ function updateAccountCard(account) {
card.querySelector('.account-info span').textContent = email;
card.title = `${displayName} <${email}>`;
if (typeof renderLabels === 'function') renderLabels();
void loadCustomFolders();
card.querySelector('.online-dot').style.background = '#70ad7b';
const profileButton = $('.top-avatar');
if (profileButton) {
@@ -499,6 +552,7 @@ if (window.daybreakMail) {
});
$('#settings-button').onclick = () => openPreferences();
$('#refresh').onclick = () => syncMailbox(true);
$('#add-folder').addEventListener('click', createMailFolder);
$$('.folder').forEach(button => button.addEventListener('click', () => {
if ($('#filter-folder').value) {
$('#filter-folder').value = '';
+2
View File
@@ -520,6 +520,8 @@
connect: (details) => EpMail.connect(details),
updateAccount: (id, details) => EpMail.updateAccount({ id, ...details }),
syncFolder: (folder, offset, filters) => EpMail.syncFolder({ folder, offset, filters }),
listFolders: () => EpMail.listFolders(),
createFolder: (name) => EpMail.createFolder({ name }),
listDrafts: () => EpMail.listDrafts(),
saveDraft: (draft) => EpMail.saveDraft(draft),
deleteDraft: (id) => EpMail.deleteDraft({ id }),
+2
View File
@@ -124,3 +124,5 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
.mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait}
body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0}
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}
.folder-add{border:0;background:transparent;color:#929990;font-size:18px;cursor:pointer}.folder-add:hover{color:#487354}.section-label+.folder-nav:empty{display:none}.custom-folder span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}