at least one account must be selected. see #326 #327

This commit is contained in:
Mic 2025-04-22 00:41:00 +02:00
parent 244dfe7743
commit 34b0a90012
2 changed files with 10 additions and 0 deletions

View file

@ -153,6 +153,11 @@ document.addEventListener('DOMContentLoaded', async () => {
document.querySelectorAll('.accountCheckbox').forEach(checkbox => {
checkbox.addEventListener('change', () => {
let selectedAccounts = Array.from(document.querySelectorAll('.accountCheckbox:checked')).map(checkbox => checkbox.value);
if (selectedAccounts.length === 0) {
checkbox.checked = true; // Prevent deselecting the last selected checkbox
taLog.log("At least one account must be selected.");
return;
}
if (selectedAccounts.length === document.querySelectorAll('.accountCheckbox').length) {
browser.storage.sync.set({ add_tags_enabled_accounts: [] });
taLog.log("All accounts selected, saving add_tags_enabled_accounts = [].");

View file

@ -110,6 +110,11 @@ document.addEventListener('DOMContentLoaded', async () => {
document.querySelectorAll('.accountCheckbox').forEach(checkbox => {
checkbox.addEventListener('change', () => {
let selectedAccounts = Array.from(document.querySelectorAll('.accountCheckbox:checked')).map(checkbox => checkbox.value);
if (selectedAccounts.length === 0) {
checkbox.checked = true; // Prevent deselecting the last selected checkbox
taLog.log("At least one account must be selected.");
return;
}
if (selectedAccounts.length === document.querySelectorAll('.accountCheckbox').length) {
browser.storage.sync.set({ spamfilter_enabled_accounts: [] });
taSpamReport.logger.log("All accounts selected, saving spamfilter_enabled_accounts = [].");