FIX account mail filtering move to folder folders are hardcoded
This commit is contained in:
@@ -64,3 +64,4 @@
|
|||||||
- [x] Fix IMAP folder creation, which does not work.
|
- [x] Fix IMAP folder creation, which does not work.
|
||||||
- [ ] Give the sidebar (Inbox, Folders, etc.) more room so every item fits on screen: make the box scrollable with a slider, or remove or collapse less-used items.
|
- [ ] Give the sidebar (Inbox, Folders, etc.) more room so every item fits on screen: make the box scrollable with a slider, or remove or collapse less-used items.
|
||||||
- [ ] Make labels work and add the ability to create more labels.
|
- [ ] Make labels work and add the ability to create more labels.
|
||||||
|
- [x] Fix created IMAP folders not showing in the mail rules folder list; only Inbox, Archive and Trash are shown.
|
||||||
|
|||||||
@@ -497,8 +497,8 @@ class EpMailPlugin : Plugin() {
|
|||||||
require(action != "move" || !value.any { it == '\r' || it == '\n' || it == '\u0000' }) {
|
require(action != "move" || !value.any { it == '\r' || it == '\n' || it == '\u0000' }) {
|
||||||
"Mail rule ${index + 1} has an invalid destination folder."
|
"Mail rule ${index + 1} has an invalid destination folder."
|
||||||
}
|
}
|
||||||
require(action != "move" || value in setOf("Inbox", "Archive", "Trash")) {
|
require(action != "move" || value in setOf("Inbox", "Archive", "Trash") || AndroidMailService.isCustomFolder(value)) {
|
||||||
"Mail rule ${index + 1} must move messages to Inbox, Archive, or Trash."
|
"Mail rule ${index + 1} must move messages to Inbox, Archive, Trash, or one of your folders."
|
||||||
}
|
}
|
||||||
result.put(JSONObject()
|
result.put(JSONObject()
|
||||||
.put("id", rule.optString("id").ifBlank { UUID.randomUUID().toString() })
|
.put("id", rule.optString("id").ifBlank { UUID.randomUUID().toString() })
|
||||||
|
|||||||
+2
-2
@@ -294,8 +294,8 @@ function normalizeAccount(input) {
|
|||||||
if ((action === 'move' || action === 'label') && !value) {
|
if ((action === 'move' || action === 'label') && !value) {
|
||||||
throw new Error(`Mail rule ${index + 1} needs a destination folder or label.`);
|
throw new Error(`Mail rule ${index + 1} needs a destination folder or label.`);
|
||||||
}
|
}
|
||||||
if (action === 'move' && !['Inbox', 'Archive', 'Trash'].includes(value)) {
|
if (action === 'move' && !['Inbox', 'Archive', 'Trash'].includes(value) && !value.startsWith(CUSTOM_FOLDER_PREFIX)) {
|
||||||
throw new Error(`Mail rule ${index + 1} must move messages to Inbox, Archive, or Trash.`);
|
throw new Error(`Mail rule ${index + 1} must move messages to Inbox, Archive, Trash, or one of your folders.`);
|
||||||
}
|
}
|
||||||
return { id: String(rule.id || randomUUID()), senderContains, subjectContains, action, value };
|
return { id: String(rule.id || randomUUID()), senderContains, subjectContains, action, value };
|
||||||
});
|
});
|
||||||
|
|||||||
+13
-3
@@ -140,6 +140,16 @@ async function loadCustomFolders() {
|
|||||||
} catch {}
|
} 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.
|
// window.prompt() is not available in Electron, so ask for text in an in-app dialog.
|
||||||
function askText(title, label, placeholder = '') {
|
function askText(title, label, placeholder = '') {
|
||||||
return new Promise(resolve => {
|
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('')}
|
${[['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>
|
</select>
|
||||||
${rule.action==='move'
|
${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':''}>`}
|
: `<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>
|
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
@@ -231,8 +241,8 @@ function openMailAccount(existingAccount = null) {
|
|||||||
const row = event.target.closest('.mail-rule-row');
|
const row = event.target.closest('.mail-rule-row');
|
||||||
const value = row.querySelector('.mail-rule-value');
|
const value = row.querySelector('.mail-rule-value');
|
||||||
if (event.target.value === 'move') {
|
if (event.target.value === 'move') {
|
||||||
const selected = ['Inbox', 'Archive', 'Trash'].includes(value.value) ? value.value : 'Inbox';
|
const selected = 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>`;
|
value.outerHTML = ruleFolderSelect(selected);
|
||||||
} else if (value.tagName === 'SELECT') {
|
} else if (value.tagName === 'SELECT') {
|
||||||
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@
|
|||||||
"build:android-web": "node scripts/prepare-android-web.cjs",
|
"build:android-web": "node scripts/prepare-android-web.cjs",
|
||||||
"android:sync": "npm run build:android-web && cap sync android",
|
"android:sync": "npm run build:android-web && cap sync android",
|
||||||
"android:open": "npm run android:sync && cap open android",
|
"android:open": "npm run android:sync && cap open android",
|
||||||
"android:apk": "npm run android:sync && node scripts/build-android-apk.cjs"
|
"android:apk": "npm run android:sync && node scripts/build-android-apk.cjs",
|
||||||
|
"build:all": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-all.ps1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@capacitor/cli": "^8.5.2",
|
"@capacitor/cli": "^8.5.2",
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Builds the Android APK and the Windows portable exe into .\release
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
Set-Location $PSScriptRoot\..
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
if (-not $env:JAVA_HOME) { $env:JAVA_HOME = 'C:\Program Files\Android\Android Studio\jbr' }
|
||||||
|
if (-not $env:ANDROID_HOME) { $env:ANDROID_HOME = Join-Path $env:LOCALAPPDATA 'Android\Sdk' }
|
||||||
|
New-Item -ItemType Directory -Force release | Out-Null
|
||||||
|
|
||||||
|
Write-Host "== Building APK $version =="
|
||||||
|
npm run android:apk
|
||||||
|
if ($LASTEXITCODE) { throw 'APK build failed' }
|
||||||
|
Copy-Item android\app\build\outputs\apk\debug\app-debug.apk "release\ep-mail $version.apk" -Force
|
||||||
|
|
||||||
|
Write-Host "== Building portable exe $version =="
|
||||||
|
npm run dist:win:portable
|
||||||
|
if ($LASTEXITCODE) { throw 'Portable build failed' }
|
||||||
|
|
||||||
|
Write-Host "`nDone:"
|
||||||
|
Get-ChildItem release | Where-Object { $_.Name -like "ep-mail $version.*" } | ForEach-Object { " $($_.FullName)" }
|
||||||
+13
-3
@@ -140,6 +140,16 @@ async function loadCustomFolders() {
|
|||||||
} catch {}
|
} 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.
|
// window.prompt() is not available in Electron, so ask for text in an in-app dialog.
|
||||||
function askText(title, label, placeholder = '') {
|
function askText(title, label, placeholder = '') {
|
||||||
return new Promise(resolve => {
|
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('')}
|
${[['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>
|
</select>
|
||||||
${rule.action==='move'
|
${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':''}>`}
|
: `<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>
|
<button type="button" class="discard remove-mail-rule" aria-label="Remove rule">Remove</button>
|
||||||
</div>`).join('');
|
</div>`).join('');
|
||||||
@@ -231,8 +241,8 @@ function openMailAccount(existingAccount = null) {
|
|||||||
const row = event.target.closest('.mail-rule-row');
|
const row = event.target.closest('.mail-rule-row');
|
||||||
const value = row.querySelector('.mail-rule-value');
|
const value = row.querySelector('.mail-rule-value');
|
||||||
if (event.target.value === 'move') {
|
if (event.target.value === 'move') {
|
||||||
const selected = ['Inbox', 'Archive', 'Trash'].includes(value.value) ? value.value : 'Inbox';
|
const selected = 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>`;
|
value.outerHTML = ruleFolderSelect(selected);
|
||||||
} else if (value.tagName === 'SELECT') {
|
} else if (value.tagName === 'SELECT') {
|
||||||
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
value.outerHTML = `<input class="mail-rule-value" maxlength="200" aria-label="Label" placeholder="Label">`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user