Add notification frequencies from nodebb-plugin-upvote-notifications. (#6640)

* Add notification frequencies from nodebb-plugin-upvote-notifications.

https://github.com/boomzillawtf/nodebb-plugin-upvote-notifications

* Fix editing settings clearing upvote notification preferences.
v1.18.x
Ben Lubar 7 years ago committed by Barış Soner Uşaklı
parent 11258dac9c
commit f1a6537fc2

@ -117,7 +117,9 @@
"no-sound": "No sound",
"upvote-notif-freq": "Upvote Notification Frequency",
"upvote-notif-freq.all": "All Upvotes",
"upvote-notif-freq.first": "First Per Post",
"upvote-notif-freq.everyTen": "Every Ten Upvotes",
"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",

@ -148,7 +148,9 @@ settingsController.get = function (req, res, callback) {
var notifFreqOptions = [
'all',
'first',
'everyTen',
'threshold',
'logarithmic',
'disabled',
];
@ -156,7 +158,7 @@ settingsController.get = function (req, res, callback) {
userData.upvoteNotifFreq = notifFreqOptions.map(function (name) {
return {
name: name,
selected: name === userData.notifFreqOptions,
selected: name === userData.settings.upvoteNotifFreq,
};
});

@ -186,9 +186,15 @@ SocketHelpers.upvote = function (data, notification) {
all: function () {
return votes > 0;
},
first: function () {
return votes === 1;
},
everyTen: function () {
return votes > 0 && votes % 10 === 0;
},
threshold: function () {
return [1, 5, 10, 25].indexOf(votes) !== -1 || (votes >= 50 && votes % 50 === 0);
},
logarithmic: function () {
return votes > 1 && Math.log10(votes) % 1 === 0;
},

Loading…
Cancel
Save