nodebb-plugin-admin-chats 3.1.0 → 3.1.1

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.
Files changed (3) hide show
  1. package/client.js +12 -8
  2. package/library.js +1 -23
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -1,14 +1,10 @@
1
1
  $(document).ready(function() {
2
- console.log(`[admin-chats] Client script loaded`);
3
2
 
4
3
  // Initialize translations object if not already set
5
4
  if (!window.adminChatsTranslations) {
6
5
  window.adminChatsTranslations = {};
7
6
  }
8
7
 
9
- console.log(`[admin-chats] ajaxify.data:`, ajaxify.data);
10
- console.log(`[admin-chats] window.adminChatsTranslations:`, window.adminChatsTranslations);
11
- console.log(`[admin-chats] window.adminChatsLanguage:`, window.adminChatsLanguage);
12
8
 
13
9
  // Get translations from ajaxify.data if available
14
10
  if (ajaxify.data && ajaxify.data.adminChatsTranslations) {
@@ -17,7 +13,6 @@ $(document).ready(function() {
17
13
  window.adminChatsAccess = ajaxify.data.adminChatsAccess;
18
14
  window.adminChatsIsAdmin = ajaxify.data.adminChatsIsAdmin;
19
15
  window.adminChatsCanManage = ajaxify.data.adminChatsCanManage;
20
- console.log(`[admin-chats] Loaded translations from ajaxify.data`);
21
16
  }
22
17
 
23
18
  syncAdminAccessFromAjaxify();
@@ -31,8 +26,6 @@ $(document).ready(function() {
31
26
  return window.adminChatsTranslations[key];
32
27
  }
33
28
  // If translation not found, log warning and return the key itself
34
- console.warn(`[admin-chats] Translation not found for key: ${key}`);
35
- console.log(`[admin-chats] Available translations:`, window.adminChatsTranslations);
36
29
  return key;
37
30
  }
38
31
 
@@ -298,7 +291,18 @@ $(document).ready(function() {
298
291
  }
299
292
 
300
293
  function getChatWindows() {
301
- return $('[component="chat/message/window"]');
294
+ const windows = new Set($('[component="chat/message/window"]').toArray());
295
+ $('.chat-modal').each(function() {
296
+ const $modal = $(this);
297
+ const nested = $modal.find('[component="chat/message/window"]').toArray();
298
+ if (nested.length) {
299
+ nested.forEach(el => windows.delete(el));
300
+ windows.add(this);
301
+ } else {
302
+ windows.add(this);
303
+ }
304
+ });
305
+ return $(Array.from(windows));
302
306
  }
303
307
 
304
308
  function getWindowRoomId($window) {
package/library.js CHANGED
@@ -30,13 +30,11 @@ function loadTranslations() {
30
30
  for (const dir of possiblePaths) {
31
31
  if (fs.existsSync(dir)) {
32
32
  languagesDir = dir;
33
- console.log(`[admin-chats] Found languages directory at: ${languagesDir}`);
34
33
  break;
35
34
  }
36
35
  }
37
36
 
38
37
  if (!languagesDir) {
39
- console.warn(`[admin-chats] Languages directory not found in any of these paths:`, possiblePaths);
40
38
  return;
41
39
  }
42
40
 
@@ -48,7 +46,6 @@ function loadTranslations() {
48
46
  if (fs.existsSync(langPath)) {
49
47
  const content = fs.readFileSync(langPath, 'utf8');
50
48
  translations[lang] = JSON.parse(content);
51
- console.log(`[admin-chats] Loaded translations for language: ${lang}`);
52
49
  }
53
50
  } catch (err) {
54
51
  console.error(`[admin-chats] Error loading translations for ${lang}:`, err.message);
@@ -241,20 +238,13 @@ plugin.filterUserNotificationsGetNotifications = async function (data) {
241
238
  return data;
242
239
  };
243
240
  async function buildAdminChatsClientContext(req) {
244
- console.log(`[admin-chats] addScripts hook called`);
245
241
  const uid = req && req.uid;
246
- console.log(`[admin-chats] addScripts called with uid: ${uid}`);
247
242
 
248
243
  let userLang = 'en-GB';
249
244
 
250
245
  if (uid) {
251
246
  try {
252
247
  const userData = await User.getUserData(uid);
253
- console.log(`[admin-chats] Full userData:`, userData);
254
- console.log(`[admin-chats] User data for uid ${uid}:`, {
255
- userLang: userData && userData.userLang,
256
- settingsUserLang: userData && userData.settings && userData.settings.userLang,
257
- });
258
248
 
259
249
  // Try different ways to get user language
260
250
  userLang = userData && userData.userLang;
@@ -265,7 +255,6 @@ async function buildAdminChatsClientContext(req) {
265
255
  // If user doesn't have specific language setting, use forum default
266
256
  if (!userLang) {
267
257
  userLang = meta.config.defaultLang || 'en-GB';
268
- console.log(`[admin-chats] Using forum default language: ${userLang}`);
269
258
  }
270
259
  } catch (err) {
271
260
  console.error(`[admin-chats] Error getting user language:`, err.message);
@@ -274,41 +263,31 @@ async function buildAdminChatsClientContext(req) {
274
263
  } else {
275
264
  // No uid, use forum default language
276
265
  userLang = meta.config.defaultLang || 'en-GB';
277
- console.log(`[admin-chats] No uid, using forum default language: ${userLang}`);
278
266
  }
279
267
 
280
268
  // Build translations based on user language from loaded files
281
269
  let clientTranslations = {};
282
270
  const langCode = userLang.split('-')[0];
283
271
 
284
- console.log(`[admin-chats] Forum default language: ${meta.config.defaultLang}`);
285
- console.log(`[admin-chats] User language: ${userLang}, Language code: ${langCode}`);
286
- console.log(`[admin-chats] Available translations:`, Object.keys(translations));
287
272
 
288
273
  // Try to get translations from loaded files
289
274
  // First try exact match (e.g., 'he-IL')
290
275
  if (translations[userLang]) {
291
276
  clientTranslations = translations[userLang];
292
- console.log(`[admin-chats] Using exact match: ${userLang}`);
293
277
  }
294
278
  // Then try language code (e.g., 'he' from 'he-IL')
295
279
  else if (translations[langCode]) {
296
280
  clientTranslations = translations[langCode];
297
- console.log(`[admin-chats] Using language code: ${langCode}`);
298
281
  }
299
282
  // Then try full locale (e.g., 'en-GB')
300
283
  else if (translations[userLang.replace('-', '-')]) {
301
284
  clientTranslations = translations[userLang];
302
- console.log(`[admin-chats] Using full locale: ${userLang}`);
303
285
  }
304
286
  // Fallback to English
305
287
  else {
306
288
  clientTranslations = translations['en'] || translations['en-GB'] || {};
307
- console.log(`[admin-chats] Using fallback (en or en-GB)`);
308
289
  }
309
290
 
310
- console.log(`[admin-chats] Sending translations:`, Object.keys(clientTranslations));
311
- console.log(`[admin-chats] clientTranslations content:`, clientTranslations);
312
291
 
313
292
  const isAdmin = uid ? await User.isAdministrator(uid) : false;
314
293
  const adminChatsManage = uid ? (isAdmin || await privileges.global.can(ADMIN_CHATS_MANAGE_PRIVILEGE, uid)) : false;
@@ -336,7 +315,6 @@ plugin.addTemplateData = async function (data) {
336
315
  templateData.adminChatsIsAdmin = context.adminChatsIsAdmin;
337
316
  templateData.adminChatsCanManage = context.adminChatsCanManage;
338
317
 
339
- console.log(`[admin-chats] Added translations to template data`);
340
318
  return data;
341
319
  };
342
320
 
@@ -358,7 +336,6 @@ plugin.addScripts = async function (data) {
358
336
  script: scriptContent
359
337
  });
360
338
 
361
- console.log(`[admin-chats] Added translations to data object and scripts`);
362
339
 
363
340
  return data;
364
341
  };
@@ -1248,3 +1225,4 @@ module.exports = plugin;
1248
1225
 
1249
1226
 
1250
1227
 
1228
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-admin-chats",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "A plugin that allows the administrator to view and manage user chats.",
5
5
  "main": "library.js",
6
6
  "nbbpm": {