Add read and flag rule actions

This commit is contained in:
Jordan Wages 2025-07-15 21:56:58 -05:00
commit 34ed955a5b
4 changed files with 46 additions and 4 deletions

View file

@ -171,7 +171,7 @@ document.addEventListener('DOMContentLoaded', async () => {
const typeWrapper = document.createElement('div');
typeWrapper.className = 'select is-small mr-2';
const typeSelect = document.createElement('select');
['tag','move','junk'].forEach(t => {
['tag','move','junk','read','flag'].forEach(t => {
const opt = document.createElement('option');
opt.value = t;
opt.textContent = t;
@ -222,6 +222,26 @@ document.addEventListener('DOMContentLoaded', async () => {
sel.value = String(action.junk ?? true);
wrap.appendChild(sel);
paramSpan.appendChild(wrap);
} else if (typeSelect.value === 'read') {
const wrap = document.createElement('div');
wrap.className = 'select is-small';
const sel = document.createElement('select');
sel.className = 'read-select';
sel.appendChild(new Option('mark read','true'));
sel.appendChild(new Option('mark unread','false'));
sel.value = String(action.read ?? true);
wrap.appendChild(sel);
paramSpan.appendChild(wrap);
} else if (typeSelect.value === 'flag') {
const wrap = document.createElement('div');
wrap.className = 'select is-small';
const sel = document.createElement('select');
sel.className = 'flag-select';
sel.appendChild(new Option('flag','true'));
sel.appendChild(new Option('unflag','false'));
sel.value = String(action.flagged ?? true);
wrap.appendChild(sel);
paramSpan.appendChild(wrap);
}
}
@ -334,6 +354,12 @@ document.addEventListener('DOMContentLoaded', async () => {
if (type === 'junk') {
return { type, junk: row.querySelector('.junk-select').value === 'true' };
}
if (type === 'read') {
return { type, read: row.querySelector('.read-select').value === 'true' };
}
if (type === 'flag') {
return { type, flagged: row.querySelector('.flag-select').value === 'true' };
}
return { type };
});
const stopProcessing = ruleEl.querySelector('.stop-processing')?.checked;
@ -474,6 +500,12 @@ document.addEventListener('DOMContentLoaded', async () => {
if (type === 'junk') {
return { type, junk: row.querySelector('.junk-select').value === 'true' };
}
if (type === 'read') {
return { type, read: row.querySelector('.read-select').value === 'true' };
}
if (type === 'flag') {
return { type, flagged: row.querySelector('.flag-select').value === 'true' };
}
return { type };
});
const stopProcessing = ruleEl.querySelector('.stop-processing')?.checked;