use same code in load room

isekai-main
Barış Soner Uşaklı 2 years ago
parent 624292524f
commit 857fe16878

@ -150,16 +150,13 @@ Messaging.getPublicRooms = async (callerUid, uid) => {
);
return unreadMids.length;
}));
const globalUserGroups = [
'registered-users', 'verified-users', 'unverified-users', 'banned-users',
];
roomData.forEach((r, idx) => {
const count = unreadCounts[idx];
r.unreadCountText = count > maxUnread ? `${maxUnread}+` : String(count);
r.unreadCount = count;
r.unread = count > 0;
const hasGroups = Array.isArray(r.groups) && r.groups.length;
r.icon = !hasGroups || r.groups.some(group => globalUserGroups.includes(group)) ? 'fa-hashtag' : 'fa-lock';
r.icon = Messaging.getRoomIcon(r);
});
return roomData;

@ -417,6 +417,7 @@ module.exports = function (Messaging) {
room.users = users;
room.canReply = canReply;
room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : users.length > 2;
room.icon = Messaging.getRoomIcon(room);
room.usernames = Messaging.generateUsernames(users, uid);
room.chatWithMessage = await Messaging.generateChatWithMessage(users, uid, settings.userLang);
room.maximumUsersInChatRoom = meta.config.maximumUsersInChatRoom;
@ -428,4 +429,13 @@ module.exports = function (Messaging) {
const payload = await plugins.hooks.fire('filter:messaging.loadRoom', { uid, data, room });
return payload.room;
};
const globalUserGroups = [
'registered-users', 'verified-users', 'unverified-users', 'banned-users',
];
Messaging.getRoomIcon = function (roomData) {
const hasGroups = Array.isArray(roomData.groups) && roomData.groups.length;
return !hasGroups || roomData.groups.some(group => globalUserGroups.includes(group)) ? 'fa-hashtag' : 'fa-lock';
};
};

Loading…
Cancel
Save