nodebb-plugin-admin-chats 3.5.0 → 3.6.0

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 (44) hide show
  1. package/README.md +12 -7
  2. package/lib/access.js +89 -0
  3. package/lib/history.js +110 -0
  4. package/lib/hooks.js +310 -0
  5. package/lib/lock.js +145 -0
  6. package/lib/overrides.js +186 -0
  7. package/lib/routes.js +469 -0
  8. package/library.js +5 -1501
  9. package/package.json +1 -1
  10. package/plugin.json +7 -6
  11. package/public/languages/ar/admin-chats.json +11 -1
  12. package/public/languages/de/admin-chats.json +11 -1
  13. package/public/languages/de-CH/admin-chats.json +11 -1
  14. package/public/languages/el/admin-chats.json +11 -1
  15. package/public/languages/en/admin-chats.json +11 -1
  16. package/public/languages/en-GB/admin-chats.json +11 -1
  17. package/public/languages/es/admin-chats.json +11 -1
  18. package/public/languages/fr/admin-chats.json +11 -1
  19. package/public/languages/fr-CH/admin-chats.json +11 -1
  20. package/public/languages/he/admin-chats.json +11 -1
  21. package/public/languages/hi/admin-chats.json +11 -1
  22. package/public/languages/it/admin-chats.json +11 -1
  23. package/public/languages/it-CH/admin-chats.json +11 -1
  24. package/public/languages/ja/admin-chats.json +11 -1
  25. package/public/languages/nl/admin-chats.json +11 -1
  26. package/public/languages/pl/admin-chats.json +11 -1
  27. package/public/languages/pt-BR/admin-chats.json +11 -1
  28. package/public/languages/rm-CH/admin-chats.json +11 -1
  29. package/public/languages/ru/admin-chats.json +11 -1
  30. package/public/languages/uk/admin-chats.json +11 -1
  31. package/public/languages/zh-CN/admin-chats.json +11 -1
  32. package/public/languages/zh-TW/admin-chats.json +11 -1
  33. package/static/lib/live-updates.js +42 -0
  34. package/static/lib/lock-toggle.js +57 -0
  35. package/static/lib/message-history.js +221 -0
  36. package/static/lib/profile-link.js +98 -0
  37. package/static/lib/switch-chat.js +234 -0
  38. package/templates/partials/chats/message-window.tpl +60 -0
  39. package/templates/partials/chats/message.tpl +83 -0
  40. package/templates/partials/chats/options.tpl +111 -0
  41. package/templates/partials/chats/recent_room.tpl +60 -0
  42. package/.github/workflows/npm-publish.yml +0 -62
  43. package/.vscode/settings.json +0 -3
  44. package/client.js +0 -917
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-admin-chats",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "A plugin that allows the administrator to view and manage user chats.",
5
5
  "main": "library.js",
6
6
  "nbbpm": {
package/plugin.json CHANGED
@@ -4,12 +4,17 @@
4
4
  "description": "A plugin that allows the administrator to view and manage user chats",
5
5
  "url": "https://github.com/palmoni5/nodebb-plugin-admin-chats",
6
6
  "library": "./library.js",
7
+ "templates": "templates",
7
8
  "scripts": [
8
- "client.js"
9
+ "static/lib/switch-chat.js",
10
+ "static/lib/lock-toggle.js",
11
+ "static/lib/live-updates.js",
12
+ "static/lib/profile-link.js",
13
+ "static/lib/message-history.js"
9
14
  ],
10
15
  "hooks": [
11
16
  {
12
- "hook": "filter:user.accountMenu",
17
+ "hook": "filter:user.profileMenu",
13
18
  "method": "addProfileLink"
14
19
  },
15
20
  {
@@ -60,10 +65,6 @@
60
65
  "hook": "filter:chat.renameRoom",
61
66
  "method": "filterRenameRoom"
62
67
  },
63
- {
64
- "hook": "filter:middleware.render",
65
- "method": "addTemplateData"
66
- },
67
68
  {
68
69
  "hook": "filter:notifications.create",
69
70
  "method": "filterNotificationCreate"
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "لا يمكن تنفيذ هذا الإجراء في غرفة مقفلة.",
9
9
  "admin-chats-view": "عرض جميع الدردشات",
10
10
  "admin-chats-manage": "إدارة غرف الدردشة",
11
- "participants": "المشاركون"
11
+ "participants": "المشاركون",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Diese Aktion kann in einem gesperrten Raum nicht ausgeführt werden.",
9
9
  "admin-chats-view": "Alle Chats ansehen",
10
10
  "admin-chats-manage": "Chat-Räume verwalten",
11
- "participants": "Teilnehmer"
11
+ "participants": "Teilnehmer",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Diese Aktion kann in einem gesperrten Raum nicht ausgeführt werden.",
9
9
  "admin-chats-view": "Alle Chats ansehen",
10
10
  "admin-chats-manage": "Chat-Räume verwalten",
11
- "participants": "Teilnehmer"
11
+ "participants": "Teilnehmer",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Αυτή η ενέργεια δεν μπορεί να εκτελεστεί σε κλειδωμένο δωμάτιο.",
9
9
  "admin-chats-view": "Προβολή όλων των συνομιλιών",
10
10
  "admin-chats-manage": "Διαχείριση δωματίων συνομιλίας",
11
- "participants": "Συμμετέχοντες"
11
+ "participants": "Συμμετέχοντες",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "This action cannot be performed in a locked room.",
9
9
  "admin-chats-view": "View all chats",
10
10
  "admin-chats-manage": "Manage chat rooms",
11
- "participants": "Participants"
11
+ "participants": "Participants",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "This action cannot be performed in a locked room.",
9
9
  "admin-chats-view": "View all chats",
10
10
  "admin-chats-manage": "Manage chat rooms",
11
- "participants": "Participants"
11
+ "participants": "Participants",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Esta acción no se puede realizar en una sala bloqueada.",
9
9
  "admin-chats-view": "Ver todos los chats",
10
10
  "admin-chats-manage": "Administrar salas de chat",
11
- "participants": "Participantes"
11
+ "participants": "Participantes",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Cette action ne peut pas être effectuée dans un salon verrouillé.",
9
9
  "admin-chats-view": "Voir tous les Chats",
10
10
  "admin-chats-manage": "Gérer les salons de discussion",
11
- "participants": "Participants"
11
+ "participants": "Participants",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Cette action ne peut pas être effectuée dans une salle verrouillée.",
9
9
  "admin-chats-view": "Voir toutes les discussions",
10
10
  "admin-chats-manage": "Gérer les salons de discussion",
11
- "participants": "Participants"
11
+ "participants": "Participants",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "לא ניתן לבצע פעולה זו בחדר נעול",
9
9
  "admin-chats-view": "צפיה בכל הצ'אטים",
10
10
  "admin-chats-manage": "ניהול חדרי צ'אט",
11
- "participants": "משתתפים"
11
+ "participants": "משתתפים",
12
+ "history.title": "היסטוריית עריכות",
13
+ "history.current": "גרסה נוכחית",
14
+ "history.revisionCount": "%1 עריכות קודמות",
15
+ "history.deleteRevision": "מחיקת גרסה",
16
+ "history.confirmDelete": "האם למחוק גרסה זו לצמיתות?",
17
+ "history.deleted": "הגרסה נמחקה",
18
+ "errors.history": "לא ניתן לטעון או לעדכן את היסטוריית העריכות.",
19
+ "history.restore": "שחזור גרסה",
20
+ "history.restored": "ההודעה שוחזרה לגרסה שנבחרה",
21
+ "history.restoreDescription": "שחזור יציב את תוכן הגרסה שנבחרה כגרסה הנוכחית; הגרסה שהוחלפה תישמר בהיסטוריה."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "लॉक किए गए कमरे में यह कार्रवाई नहीं की जा सकती।",
9
9
  "admin-chats-view": "सभी चैट देखें",
10
10
  "admin-chats-manage": "चैट रूम प्रबंधित करें",
11
- "participants": "प्रतिभागी"
11
+ "participants": "प्रतिभागी",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Questa azione non può essere eseguita in una stanza bloccata.",
9
9
  "admin-chats-view": "Visualizza tutte le chat",
10
10
  "admin-chats-manage": "Gestisci le stanze di chat",
11
- "participants": "Partecipanti"
11
+ "participants": "Partecipanti",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Questa azione non può essere eseguita in una stanza bloccata.",
9
9
  "admin-chats-view": "Visualizza tutte le chat",
10
10
  "admin-chats-manage": "Gestisci le stanze di chat",
11
- "participants": "Partecipanti"
11
+ "participants": "Partecipanti",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "ロックされたルームではこの操作は実行できません。",
9
9
  "admin-chats-view": "すべてのチャットを見る",
10
10
  "admin-chats-manage": "チャットルームを管理",
11
- "participants": "参加者"
11
+ "participants": "参加者",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Deze actie kan niet worden uitgevoerd in een vergrendelde chatruimte.",
9
9
  "admin-chats-view": "Alle chats bekijken",
10
10
  "admin-chats-manage": "Chatruimtes beheren",
11
- "participants": "Deelnemers"
11
+ "participants": "Deelnemers",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Tej czynności nie można wykonać w zablokowanym pokoju.",
9
9
  "admin-chats-view": "Wyświetl wszystkie czaty",
10
10
  "admin-chats-manage": "Zarządzaj pokojami czatu",
11
- "participants": "Uczestnicy"
11
+ "participants": "Uczestnicy",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Esta ação não pode ser realizada em uma sala bloqueada.",
9
9
  "admin-chats-view": "Ver todos os chats",
10
10
  "admin-chats-manage": "Gerenciar salas de chat",
11
- "participants": "Participantes"
11
+ "participants": "Participantes",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Questa acziun na po betg vegnir fatga en in local bloccà.",
9
9
  "admin-chats-view": "Veser tut ils chats",
10
10
  "admin-chats-manage": "Administrar locals da chat",
11
- "participants": "Participonts"
11
+ "participants": "Participonts",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Это действие нельзя выполнить в заблокированной комнате.",
9
9
  "admin-chats-view": "Просмотреть все чаты",
10
10
  "admin-chats-manage": "Управлять чат-комнатами",
11
- "participants": "Участники"
11
+ "participants": "Участники",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "Цю дію не можна виконати в блокованій кімнаті.",
9
9
  "admin-chats-view": "Переглянути всі чати",
10
10
  "admin-chats-manage": "Керувати чат-кімнатами",
11
- "participants": "Учасники"
11
+ "participants": "Учасники",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "锁定的聊天室无法执行此操作。",
9
9
  "admin-chats-view": "查看所有聊天",
10
10
  "admin-chats-manage": "管理聊天室",
11
- "participants": "参与者"
11
+ "participants": "参与者",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -8,5 +8,15 @@
8
8
  "errors.lockedAction": "鎖定的聊天室無法執行此操作。",
9
9
  "admin-chats-view": "查看所有聊天",
10
10
  "admin-chats-manage": "管理聊天室",
11
- "participants": "參與者"
11
+ "participants": "參與者",
12
+ "history.title": "Edit History",
13
+ "history.current": "Current version",
14
+ "history.revisionCount": "%1 previous edits",
15
+ "history.deleteRevision": "Delete version",
16
+ "history.confirmDelete": "Permanently delete this version?",
17
+ "history.deleted": "Version deleted",
18
+ "errors.history": "Unable to load or update the edit history.",
19
+ "history.restore": "Restore version",
20
+ "history.restored": "Message restored to the selected version",
21
+ "history.restoreDescription": "Restoring sets the selected version as the current one; the replaced version is kept in the history."
12
22
  }
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ // Pushes room-lock changes to anyone with that room open, instead of the
4
+ // previous approach of polling every open chat window on a timer. The
5
+ // server emits event:admin-chats.roomLockChanged to chat_room_<roomId> from
6
+ // lib/routes.js's lock endpoint (mirrors core's own room broadcast pattern
7
+ // in src/messaging/notifications.js).
8
+ $(document).ready(function () {
9
+ function refreshIfOpen(roomId) {
10
+ const activeRoomId = parseInt($('[component="chat/main-wrapper"]').attr('data-roomid'), 10) || 0;
11
+ if (activeRoomId !== parseInt(roomId, 10)) {
12
+ return;
13
+ }
14
+
15
+ require(['forum/chats'], function (Chats) {
16
+ if (Chats && Chats.switchChat) {
17
+ Chats.switchChat(roomId);
18
+ }
19
+ });
20
+ }
21
+
22
+ if (window.socket) {
23
+ socket.removeListener('event:admin-chats.roomLockChanged', refreshIfOpen);
24
+ socket.on('event:admin-chats.roomLockChanged', function (data) {
25
+ refreshIfOpen(data && data.roomId);
26
+ });
27
+ }
28
+
29
+ // Core toggles the `deleted` class on a message when it's deleted/restored,
30
+ // but doesn't itself swap which of the delete/restore actions is visible.
31
+ $(document).on('click', '[data-action="delete"], [data-action="restore"]', function () {
32
+ const $message = $(this).closest('[component="chat/message"]');
33
+ if (!$message.length) {
34
+ return;
35
+ }
36
+ setTimeout(function () {
37
+ const isDeleted = $message.hasClass('deleted');
38
+ $message.find('[data-action="delete"]').toggleClass('hidden', isDeleted).toggle(!isDeleted);
39
+ $message.find('[data-action="restore"]').toggleClass('hidden', !isDeleted).toggle(isDeleted);
40
+ }, 50);
41
+ });
42
+ });
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ // The lock/unlock menu item itself is rendered server-side
4
+ // (templates/partials/chats/options.tpl, gated on isAdminOrGlobalMod) — this
5
+ // only wires the click. The resulting UI state (composer, per-message
6
+ // actions, banner) all comes from the server re-render below, not from
7
+ // client-side DOM patching.
8
+ $(document).ready(function () {
9
+ async function toggleRoomLock(roomId, nextState) {
10
+ const response = await fetch(`${config.relative_path || ''}/api/admin-chats/${roomId}/lock`, {
11
+ method: 'POST',
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ 'x-csrf-token': config.csrf_token,
15
+ },
16
+ body: JSON.stringify({ locked: nextState }),
17
+ credentials: 'same-origin',
18
+ });
19
+
20
+ if (!response.ok) {
21
+ throw new Error('Unable to update room lock');
22
+ }
23
+
24
+ return await response.json();
25
+ }
26
+
27
+ $(document).on('click', '.admin-chat-lock-toggle-item', async function (ev) {
28
+ ev.preventDefault();
29
+
30
+ const $button = $(this);
31
+ const roomId = parseInt($button.attr('data-room-id'), 10);
32
+ const isLocked = $button.attr('data-locked') === 'true';
33
+
34
+ if (!roomId) {
35
+ return;
36
+ }
37
+
38
+ $button.addClass('disabled').attr('aria-disabled', 'true');
39
+
40
+ try {
41
+ await toggleRoomLock(roomId, !isLocked);
42
+ // The lock/unlock menu item, composer visibility and per-message
43
+ // action buttons are all rendered server-side from the fresh
44
+ // room data, so re-switch to this room to pick it up. Other
45
+ // clients with the room open get the same refresh via the
46
+ // event:admin-chats.roomLockChanged broadcast (static/lib/live-updates.js).
47
+ require(['forum/chats'], function (Chats) {
48
+ if (Chats && Chats.switchChat) {
49
+ Chats.switchChat(roomId);
50
+ }
51
+ });
52
+ } catch (err) {
53
+ app.alertError('[[admin-chats:errors.update]]');
54
+ $button.removeClass('disabled').removeAttr('aria-disabled');
55
+ }
56
+ });
57
+ });