Skip to content

Node.js based forum software built for the modern web

fix: #8838, fix chat dropdown timestamps

Barış Soner Uşaklı78ee83324c59
diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js
index ec33db51f7..680022049e 100644
--- a/public/src/modules/chat.js
+++ b/public/src/modules/chat.js
@@ -3,7 +3,8 @@
define('chat', [
'components',
'taskbar',
-], function (components, taskbar) {
+ 'translator',
+], function (components, taskbar, translator) {
var module = {};
var newMessage = false;
@@ -20,28 +21,34 @@ define('chat', [
return room.teaser;
});
- app.parseAndTranslate('partials/chats/dropdown', { rooms: rooms }, function (html) {
- chatsListEl.find('*').not('.navigation-link').remove();
- chatsListEl.prepend(html);
- app.createUserTooltips(chatsListEl, 'right');
- chatsListEl.off('click').on('click', '[data-roomid]', function (ev) {
- if ($(ev.target).parents('.user-link').length) {
- return;
- }
- var roomId = $(this).attr('data-roomid');
- if (!ajaxify.currentPage.match(/^chats\//)) {
- app.openChat(roomId);
- } else {
- ajaxify.go('user/' + app.user.userslug + '/chats/' + roomId);
- }
- });
-
- $('[component="chats/mark-all-read"]').off('click').on('click', function () {
- socket.emit('modules.chats.markAllRead', function (err) {
- if (err) {
- return app.alertError(err);
+ translator.toggleTimeagoShorthand(function () {
+ for (var i = 0; i < rooms.length; i += 1) {
+ rooms[i].teaser.timeago = $.timeago(new Date(parseInt(rooms[i].teaser.timestamp, 10)));
+ }
+ translator.toggleTimeagoShorthand();
+ app.parseAndTranslate('partials/chats/dropdown', { rooms: rooms }, function (html) {
+ chatsListEl.find('*').not('.navigation-link').remove();
+ chatsListEl.prepend(html);
+ app.createUserTooltips(chatsListEl, 'right');
+ chatsListEl.off('click').on('click', '[data-roomid]', function (ev) {
+ if ($(ev.target).parents('.user-link').length) {
+ return;
+ }
+ var roomId = $(this).attr('data-roomid');
+ if (!ajaxify.currentPage.match(/^chats\//)) {
+ app.openChat(roomId);
+ } else {
+ ajaxify.go('user/' + app.user.userslug + '/chats/' + roomId);
}
});
+
+ $('[component="chats/mark-all-read"]').off('click').on('click', function () {
+ socket.emit('modules.chats.markAllRead', function (err) {
+ if (err) {
+ return app.alertError(err);
+ }
+ });
+ });
});
});
});