mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 08:55:47 +01:00
feat: on online users page override timeago cutoff to 24 hours
This commit is contained in:
@@ -239,6 +239,7 @@ app.flags = {};
|
||||
|
||||
app.processPage = function () {
|
||||
highlightNavigationLink();
|
||||
overrides.overrideTimeagoCutoff();
|
||||
$('.timeago').timeago();
|
||||
utils.makeNumbersHumanReadable($('.human-readable-number'));
|
||||
utils.addCommasToNumbers($('.formatted-number'));
|
||||
|
||||
@@ -109,16 +109,21 @@ if (typeof window !== 'undefined') {
|
||||
});
|
||||
}());
|
||||
let timeagoFn;
|
||||
overrides.overrideTimeagoCutoff = function () {
|
||||
const cutoff = parseInt(ajaxify.data.timeagoCutoff || config.timeagoCutoff, 10);
|
||||
if (cutoff === 0) {
|
||||
$.timeago.settings.cutoff = 1;
|
||||
} else if (cutoff > 0) {
|
||||
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * cutoff;
|
||||
}
|
||||
};
|
||||
|
||||
overrides.overrideTimeago = function () {
|
||||
if (!timeagoFn) {
|
||||
timeagoFn = $.fn.timeago;
|
||||
}
|
||||
|
||||
if (parseInt(config.timeagoCutoff, 10) === 0) {
|
||||
$.timeago.settings.cutoff = 1;
|
||||
} else if (parseInt(config.timeagoCutoff, 10) > 0) {
|
||||
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * (parseInt(config.timeagoCutoff, 10) || 30);
|
||||
}
|
||||
overrides.overrideTimeagoCutoff();
|
||||
|
||||
$.timeago.settings.allowFuture = true;
|
||||
const userLang = config.userLang.replace('_', '-');
|
||||
|
||||
@@ -61,6 +61,7 @@ usersController.getOnlineUsers = async function (req, res) {
|
||||
}
|
||||
|
||||
userData.anonymousUserCount = guests + hiddenCount;
|
||||
userData.timeagoCutoff = 1000 * 60 * 60 * 24;
|
||||
|
||||
await render(req, res, userData);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user