Added setting to enable e-mail on quick alerts.

This commit is contained in:
2026-11-12 22:44:07 +01:00
parent 38049937d5
commit 7d9ffba29c
3 changed files with 22 additions and 4 deletions
+2 -4
View File
@@ -124,10 +124,8 @@ async function alertItem() {
...(props.domain === 'entities' && { entities: [props.item.id] }),
...(props.domain === 'scenes' && { scenes: [props.item.id] }),
notify: true,
email: false,
// probably too confusing and annoying to have quick alerts inherit email preference from dialog
// notify: JSON.parse(localStorage.getItem('alert_notify')) ?? true,
// email: JSON.parse(localStorage.getItem('alert_email')) ?? false,
// explicit user preference rather than the dialog's remembered checkbox, which would be too confusing to inherit
email: !!(user.settings?.quickAlertEmails && user.email),
preset: true,
}, {
successFeedback: `Alert set for '${alertLabel}'`,
+15
View File
@@ -12,6 +12,7 @@ const settings = reactive({
alertNotificationsEnabled: true,
alertEmailsEnabled: true,
alertEmailsFrequency: null,
quickAlertEmails: false,
...user.settings,
});
@@ -53,6 +54,20 @@ async function updateSettings() {
</span>
</div>
<div class="setting noflip">
<span class="setting-label">
<strong class="setting-title">E-mail quick alerts</strong>
<span class="setting-description">Enable e-mail on alerts set with the bell button</span>
</span>
<span class="setting-value">
<Checkbox
:checked="settings.quickAlertEmails"
@change="(checked) => { settings.quickAlertEmails = checked; updateSettings(); }"
/>
</span>
</div>
<div class="setting">
<span class="setting-label">
<strong class="setting-title">Alert e-mail frequency</strong>
+5
View File
@@ -580,6 +580,7 @@ const validSettingKeys = [
'alertNotificationsEnabled',
'alertEmailsEnabled',
'alertEmailsFrequency',
'quickAlertEmails',
];
export async function updateSettings(settings, reqUser) {
@@ -593,6 +594,10 @@ export async function updateSettings(settings, reqUser) {
throw new HttpError(`Invalid settings: ${invalidKeys.join()}`, 400);
}
if (Object.hasOwn(settings, 'quickAlertEmails') && typeof settings.quickAlertEmails !== 'boolean') {
throw new HttpError('Invalid quick alert e-mails setting', 400);
}
if (settings.alertEmailsFrequency && !['instant', 'daily', 'weekly', 'monthly'].includes(settings.alertEmailsFrequency)) {
throw new HttpError('Invalid email frequency setting', 400);
}