Skip to content

Node.js based forum software built for the modern web

feat: hide read notifications toggle in UCP, #14191

Julian Lam5adeb12785b5
diff --git a/install/package.json b/install/package.json
index 14021f4e78..c25389806f 100644
--- a/install/package.json
+++ b/install/package.json
@@ -109,7 +109,7 @@
"nodebb-plugin-spam-be-gone": "2.3.2",
"nodebb-plugin-web-push": "0.7.7",
"nodebb-rewards-essentials": "1.0.2",
- "nodebb-theme-harmony": "2.2.64",
+ "nodebb-theme-harmony": "2.2.65",
"nodebb-theme-lavender": "7.1.21",
"nodebb-theme-peace": "2.2.58",
"nodebb-theme-persona": "14.2.35",
@@ -205,4 +205,4 @@
"url": "https://github.com/barisusakli"
}
]
-}
\ No newline at end of file
+}
diff --git a/public/language/en-GB/user.json b/public/language/en-GB/user.json
index 4fdb92fd43..d212f46505 100644
--- a/public/language/en-GB/user.json
+++ b/public/language/en-GB/user.json
@@ -155,6 +155,7 @@
"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",
+ "hide-read-notifications": "Hide Read Notifications",
"notification-type-web": "Web",
"notification-type-email": "Email",
diff --git a/src/controllers/api.js b/src/controllers/api.js
index ba49ccb29c..d01e3844c9 100644
--- a/src/controllers/api.js
+++ b/src/controllers/api.js
@@ -140,6 +140,7 @@ apiController.loadConfig = async function (req) {
config.bootswatchSkin = settings.bootswatchSkin;
}
}
+ config.hideReadNotifications = settings.hideReadNotifications;
// Overrides based on privilege
config.disableChatMessageEditing = isAdminOrGlobalMod ? false : config.disableChatMessageEditing;
diff --git a/src/user/notifications.js b/src/user/notifications.js
index a7d2d38215..fd47cf1122 100644
--- a/src/user/notifications.js
+++ b/src/user/notifications.js
@@ -16,6 +16,8 @@ const user = require('./index');
const UserNotifications = module.exports;
UserNotifications.get = async function (uid) {
+ const { hideReadNotifications } = await user.getSettings(uid);
+
if (parseInt(uid, 10) <= 0) {
return { read: [], unread: [] };
}
@@ -23,7 +25,7 @@ UserNotifications.get = async function (uid) {
let unread = await getNotificationsFromSet(`uid:${uid}:notifications:unread`, uid, 0, 49);
unread = unread.filter(Boolean);
let read = [];
- if (unread.length < 50) {
+ if (!hideReadNotifications && unread.length < 50) {
read = await getNotificationsFromSet(`uid:${uid}:notifications:read`, uid, 0, 49 - unread.length);
}
diff --git a/src/user/settings.js b/src/user/settings.js
index 7c52d1f2f0..6f82758caf 100644
--- a/src/user/settings.js
+++ b/src/user/settings.js
@@ -91,6 +91,7 @@ module.exports = function (User) {
settings.homePageRoute = validator.escape(String(settings.homePageRoute || '')).replace(/&#x2F;/g, '/');
settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) === 1;
settings.categoryWatchState = getSetting(settings, 'categoryWatchState', 'notwatching');
+ settings.hideReadNotifications = parseInt(getSetting(settings, 'hideReadNotifications', 0), 10) === 1;
const notificationTypes = await notifications.getAllNotificationTypes();
notificationTypes.forEach((notificationType) => {
@@ -147,6 +148,7 @@ module.exports = function (User) {
homePageRoute: ((data.homePageRoute === 'custom' ? data.homePageCustom : data.homePageRoute) || '').replace(/^\//, ''),
scrollToMyPost: data.scrollToMyPost,
upvoteNotifFreq: data.upvoteNotifFreq,
+ hideReadNotifications: data.hideReadNotifications,
bootswatchSkin: data.bootswatchSkin,
categoryWatchState: data.categoryWatchState,
categoryTopicSort: data.categoryTopicSort,