feat: on online users page override timeago cutoff to 24 hours

isekai-main
Barış Soner Uşaklı 3 years ago
parent df8ea4bad3
commit 7c946570d5

@ -239,6 +239,7 @@ app.flags = {};
app.processPage = function () { app.processPage = function () {
highlightNavigationLink(); highlightNavigationLink();
overrides.overrideTimeagoCutoff();
$('.timeago').timeago(); $('.timeago').timeago();
utils.makeNumbersHumanReadable($('.human-readable-number')); utils.makeNumbersHumanReadable($('.human-readable-number'));
utils.addCommasToNumbers($('.formatted-number')); utils.addCommasToNumbers($('.formatted-number'));

@ -109,16 +109,21 @@ if (typeof window !== 'undefined') {
}); });
}()); }());
let timeagoFn; 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 () { overrides.overrideTimeago = function () {
if (!timeagoFn) { if (!timeagoFn) {
timeagoFn = $.fn.timeago; timeagoFn = $.fn.timeago;
} }
if (parseInt(config.timeagoCutoff, 10) === 0) { overrides.overrideTimeagoCutoff();
$.timeago.settings.cutoff = 1;
} else if (parseInt(config.timeagoCutoff, 10) > 0) {
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * (parseInt(config.timeagoCutoff, 10) || 30);
}
$.timeago.settings.allowFuture = true; $.timeago.settings.allowFuture = true;
const userLang = config.userLang.replace('_', '-'); const userLang = config.userLang.replace('_', '-');

@ -61,6 +61,7 @@ usersController.getOnlineUsers = async function (req, res) {
} }
userData.anonymousUserCount = guests + hiddenCount; userData.anonymousUserCount = guests + hiddenCount;
userData.timeagoCutoff = 1000 * 60 * 60 * 24;
await render(req, res, userData); await render(req, res, userData);
}; };

Loading…
Cancel
Save