FIX account mail filtering move to folder folders are hardcoded
This commit is contained in:
+13
-3
@@ -140,6 +140,16 @@ async function loadCustomFolders() {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders.
|
||||
function ruleFolderSelect(selected = 'Inbox') {
|
||||
const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...customFolders.map(folder => [folder.id, folder.name])];
|
||||
if (!options.some(([value]) => value === selected)) {
|
||||
options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]);
|
||||
}
|
||||
return '<select class="mail-rule-value" aria-label="Destination folder">' +
|
||||
options.map(([value, name]) => '<option value="' + esc(value) + '"' + (value === selected ? ' selected' : '') + '>' + esc(name) + '</option>').join('') + '</select>';
|
||||
}
|
||||
|
||||
// window.prompt() is not available in Electron, so ask for text in an in-app dialog.
|
||||
function askText(title, label, placeholder = '') {
|
||||
return new Promise(resolve => {
|
||||
@@ -206,7 +216,7 @@ function openMailAccount(existingAccount = null) {
|
||||
${[['archive','Archive'],['move','Move to folder'],['label','Apply label'],['flag','Flag']].map(([value,label])=>`<option value="${value}"${rule.action===value?' selected':''}>${label}</option>`).join('')}
|
||||
</select>
|
||||
${rule.action==='move'
|
||||
? `<select class="mail-rule-value" aria-label="Destination folder"><option value="Inbox"${rule.value==='Inbox'?' selected':''}>Inbox</option><option value="Archive"${rule.value==='Archive'?' selected':''}>Archive</option><option value="Trash"${rule.value==='Trash'?' selected':''}>Trash</option></select>`
|
||||
? `${ruleFolderSelect(rule.value)}`
|
||||
: `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label" value="${esc(rule.value || '')}"${rule.action==='flag'?' disabled':''}>`}
|
||||
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||
</div>`).join('');
|
||||
@@ -231,8 +241,8 @@ function openMailAccount(existingAccount = null) {
|
||||
const row = event.target.closest('.mail-rule-row');
|
||||
const value = row.querySelector('.mail-rule-value');
|
||||
if (event.target.value === 'move') {
|
||||
const selected = ['Inbox', 'Archive', 'Trash'].includes(value.value) ? value.value : 'Inbox';
|
||||
value.outerHTML = `<select class="mail-rule-value" aria-label="Destination folder"><option value="Inbox"${selected==='Inbox'?' selected':''}>Inbox</option><option value="Archive"${selected==='Archive'?' selected':''}>Archive</option><option value="Trash"${selected==='Trash'?' selected':''}>Trash</option></select>`;
|
||||
const selected = value.value || 'Inbox';
|
||||
value.outerHTML = ruleFolderSelect(selected);
|
||||
} else if (value.tagName === 'SELECT') {
|
||||
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user