Skip to content

Node.js based forum software built for the modern web

feat: change notif controls to toggles

Barış Soner Uşaklı523e3b496424
diff --git a/install/package.json b/install/package.json
index 839a9d6a30..c4383280df 100644
--- a/install/package.json
+++ b/install/package.json
@@ -107,10 +107,10 @@
"nodebb-plugin-spam-be-gone": "2.3.2",
"nodebb-plugin-web-push": "0.7.6",
"nodebb-rewards-essentials": "1.0.2",
- "nodebb-theme-harmony": "2.2.21",
+ "nodebb-theme-harmony": "2.2.23",
"nodebb-theme-lavender": "7.1.21",
"nodebb-theme-peace": "2.2.51",
- "nodebb-theme-persona": "14.2.13",
+ "nodebb-theme-persona": "14.2.15",
"nodebb-widget-essentials": "7.0.42",
"nodemailer": "8.0.1",
"nprogress": "0.2.0",
diff --git a/public/language/en-GB/notifications.json b/public/language/en-GB/notifications.json
index d4aa2cc16b..a02d2f6305 100644
--- a/public/language/en-GB/notifications.json
+++ b/public/language/en-GB/notifications.json
@@ -93,9 +93,9 @@
"notificationType-upvote": "When someone upvotes your post",
"notificationType-new-topic": "When someone you follow posts a topic",
"notificationType-new-topic-with-tag": "When a topic is posted with a tag you follow",
- "notificationType-new-topic-in-category": "When a topic is posted in a category you are watching",
- "notificationType-new-reply": "When a new reply is posted in a topic you are watching",
- "notificationType-post-edit": "When a post is edited in a topic you are watching",
+ "notificationType-new-topic-in-category": "When a topic is posted in a watched category",
+ "notificationType-new-reply": "When a reply is posted in a watched topic",
+ "notificationType-post-edit": "When a post is edited in a watched topic",
"notificationType-follow": "When someone starts following you",
"notificationType-new-chat": "When you receive a chat message",
"notificationType-new-group-chat": "When you receive a group chat message",
diff --git a/public/language/en-GB/user.json b/public/language/en-GB/user.json
index c3e54eef2a..4fdb92fd43 100644
--- a/public/language/en-GB/user.json
+++ b/public/language/en-GB/user.json
@@ -155,6 +155,8 @@
"upvote-notif-freq.threshold": "On 1, 5, 10, 25, 50, 100, 150, 200...",
"upvote-notif-freq.logarithmic": "On 10, 100, 1000...",
"upvote-notif-freq.disabled": "Disabled",
+ "notification-type-web": "Web",
+ "notification-type-email": "Email",
"browsing": "Browsing Settings",
"unread.cutoff": "Unread cutoff (Maximum %1 days)",
diff --git a/public/openapi/read/user/userslug/settings.yaml b/public/openapi/read/user/userslug/settings.yaml
index 2722958aaa..01bfe7c2bd 100644
--- a/public/openapi/read/user/userslug/settings.yaml
+++ b/public/openapi/read/user/userslug/settings.yaml
@@ -73,6 +73,8 @@ get:
type: string
label:
type: string
+ value:
+ type: string
none:
type: boolean
notification:
diff --git a/public/src/client/account/settings.js b/public/src/client/account/settings.js
index f7c41a4006..be4d422cc6 100644
--- a/public/src/client/account/settings.js
+++ b/public/src/client/account/settings.js
@@ -49,6 +49,8 @@ define('forum/account/settings', [
components.get('user/sessions').find('.timeago').timeago();
handleChatAllowDenyList();
+
+ handleNotificationToggles();
};
function loadSettings() {
@@ -224,5 +226,24 @@ define('forum/account/settings', [
}
}
+ function handleNotificationToggles() {
+ $('[component="notification/table"]').on('click', '[data-value]', function () {
+ const $el = $(this);
+ const isTurnedOn = parseInt($el.attr('data-value'), 10) === 0;
+ $el.attr('data-value', isTurnedOn ? 1 : 0);
+ $el.find('i').first().toggleClass('hidden', !isTurnedOn);
+ $el.find('i').last().toggleClass('hidden', isTurnedOn);
+
+ const row = $el.parents('[component="notification/setting"]');
+ const isNotifOn = row.find('[data-type="notification"]').attr('data-value') === '1';
+ const isEmailOn = row.find('[data-type="email"]').attr('data-value') === '1';
+ const newSelectValue = [
+ isNotifOn && 'notification',
+ isEmailOn && 'email',
+ ].filter(Boolean).join('') || 'none';
+ row.find('input[data-property]').val(newSelectValue);
+ });
+ }
+
return AccountSettings;
});
diff --git a/src/controllers/accounts/settings.js b/src/controllers/accounts/settings.js
index dbc453ec2c..61754e2561 100644
--- a/src/controllers/accounts/settings.js
+++ b/src/controllers/accounts/settings.js
@@ -189,6 +189,7 @@ async function getNotificationSettings(userData) {
return {
name: type,
label: `[[notifications:${type.replace(/_/g, '-')}]]`,
+ value: setting,
none: setting === 'none',
notification: setting === 'notification',
email: setting === 'email',