feat: add new language string for chat usernames

This commit is contained in:
Barış Soner Uşaklı
2023-01-12 13:32:39 -05:00
parent 8036baf86a
commit 32cad6dc82
2 changed files with 14 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
"chat.chatting_with": "Chat with",
"chat.placeholder": "Type chat message here, drag & drop images, press enter to send",
"chat.scroll-up-alert": "You are looking at older messages, click here to go to most recent message.",
"chat.usernames-and-x-others": "%1 & %2 others",
"chat.send": "Send",
"chat.no_active": "You have no active chats.",
"chat.user_typing": "%1 is typing ...",

View File

@@ -9,6 +9,7 @@ const privileges = require('../privileges');
const plugins = require('../plugins');
const meta = require('../meta');
const utils = require('../utils');
const translator = require('../translator');
const Messaging = module.exports;
@@ -137,8 +138,18 @@ Messaging.getRecentChats = async (callerUid, uid, start, stop) => {
});
};
Messaging.generateUsernames = (users, excludeUid) => users.filter(user => user && parseInt(user.uid, 10) !== excludeUid)
.map(user => user.username).join(', ');
Messaging.generateUsernames = function (users, excludeUid) {
users = users.filter(u => u && parseInt(u.uid, 10) !== excludeUid);
const usernames = users.map(u => u.username);
if (users.length > 2) {
return translator.compile(
'modules:chat.usernames-and-x-others',
usernames.slice(0, 2).join(', '),
usernames.length - 2
);
}
return usernames.join(', ');
};
Messaging.getTeaser = async (uid, roomId) => {
const mid = await Messaging.getLatestUndeletedMessage(uid, roomId);