nodebb-plugin-admin-chats 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +7 -4
- package/library.js +10 -4
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -24,14 +24,17 @@ $(document).ready(function() {
|
|
|
24
24
|
|
|
25
25
|
$(window).on('action:ajaxify.end', function(ev, data) {
|
|
26
26
|
|
|
27
|
-
if (app.user.isAdmin &&
|
|
27
|
+
if (app.user.isAdmin && ajaxify.data.template.name.startsWith('account/')) {
|
|
28
28
|
const userSlug = ajaxify.data.userslug || (ajaxify.data.user && ajaxify.data.user.userslug);
|
|
29
|
+
|
|
29
30
|
if (userSlug) {
|
|
30
|
-
const buttonText = isEnglishSystem() ? "View Chats" : "
|
|
31
|
+
const buttonText = isEnglishSystem() ? "View Chats" : "צפיה בצ'אטים";
|
|
32
|
+
|
|
33
|
+
const relativePath = config.relative_path || '';
|
|
31
34
|
|
|
32
35
|
const btnHtml = `
|
|
33
36
|
<li role="presentation">
|
|
34
|
-
<a class="dropdown-item rounded-1 d-flex align-items-center gap-2" href="/user/${userSlug}/chats" role="menuitem">
|
|
37
|
+
<a class="dropdown-item rounded-1 d-flex align-items-center gap-2" href="${relativePath}/user/${userSlug}/chats" role="menuitem">
|
|
35
38
|
<i class="far fa-fw fa-comments"></i>
|
|
36
39
|
<span>${buttonText}</span>
|
|
37
40
|
</a>
|
|
@@ -56,4 +59,4 @@ $(document).ready(function() {
|
|
|
56
59
|
$(window).on('action:chat.closed', function() {
|
|
57
60
|
setTimeout(replaceAdminEmptyStateText, 200);
|
|
58
61
|
});
|
|
59
|
-
});
|
|
62
|
+
});
|
package/library.js
CHANGED
|
@@ -89,7 +89,6 @@ plugin.canGetPublicChats = async function (payload) {
|
|
|
89
89
|
plugin.onLoadRoom = async function (payload) {
|
|
90
90
|
const { uid, room } = payload;
|
|
91
91
|
const isAdmin = await User.isAdministrator(uid);
|
|
92
|
-
|
|
93
92
|
if (!isAdmin || !room) return payload;
|
|
94
93
|
|
|
95
94
|
const isOfficialMember = await db.isSortedSetMember(`chat:room:${room.roomId}:uids`, uid);
|
|
@@ -100,7 +99,6 @@ plugin.onLoadRoom = async function (payload) {
|
|
|
100
99
|
if (Array.isArray(room.users)) {
|
|
101
100
|
room.users = room.users.filter(user => user && parseInt(user.uid, 10) !== parseInt(uid, 10));
|
|
102
101
|
}
|
|
103
|
-
|
|
104
102
|
if (room.userCount > 0) {
|
|
105
103
|
room.userCount -= 1;
|
|
106
104
|
}
|
|
@@ -118,14 +116,22 @@ plugin.onLoadRoom = async function (payload) {
|
|
|
118
116
|
});
|
|
119
117
|
|
|
120
118
|
room.messages = messages.reverse();
|
|
121
|
-
}
|
|
122
119
|
|
|
120
|
+
room.messages.forEach((msg, index) => {
|
|
121
|
+
if (index === 0) {
|
|
122
|
+
msg.newSet = true;
|
|
123
|
+
} else {
|
|
124
|
+
const prevMsg = room.messages[index - 1];
|
|
125
|
+
msg.newSet = parseInt(msg.fromuid, 10) !== parseInt(prevMsg.fromuid, 10);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
room.isAdmin = true;
|
|
124
131
|
room.isOwner = true;
|
|
125
132
|
} else {
|
|
126
133
|
room.isAdmin = true;
|
|
127
134
|
}
|
|
128
|
-
|
|
129
135
|
return payload;
|
|
130
136
|
};
|
|
131
137
|
|