nodebb-plugin-admin-chats 3.8.0 → 3.8.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/lib/hooks.js CHANGED
@@ -243,7 +243,11 @@ hooks.onLoadRoom = async function (payload) {
243
243
  isLockedForUser
244
244
  );
245
245
  room.canReply = room.canReply && !isLockedForUser;
246
- room.showUserInput = room.showUserInput && !isLockedForUser;
246
+ // The composer in partials/chats/message-window.tpl is wrapped in {{{ if showUserInput }}}.
247
+ // Core sets showUserInput = false whenever "maximum users in chat room" is 2 (the flag was
248
+ // meant for the add-user field and core templates no longer use it), which hid the message
249
+ // box on /chats - the page phones use. Only hide it when the room is locked for the viewer.
250
+ room.showUserInput = !isLockedForUser;
247
251
 
248
252
  if (!hasAccess) {
249
253
  return payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-admin-chats",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "description": "A plugin that allows the administrator to view and manage user chats.",
5
5
  "main": "library.js",
6
6
  "nbbpm": {
@@ -25,18 +25,4 @@ $(document).ready(function () {
25
25
  refreshIfOpen(data && data.roomId);
26
26
  });
27
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
28
  });
@@ -192,6 +192,12 @@ $(document).ready(function () {
192
192
  if (!isAdminAllChatsPage()) {
193
193
  return;
194
194
  }
195
+ // On back/forward away from the chats page ajaxify.data still describes the chats
196
+ // page until the next page finishes loading. Without this check the room list is
197
+ // "switched" to and /chats is pushed on top of the page the user is navigating to.
198
+ if (!/\/chats(\/|$)/.test(window.location.pathname)) {
199
+ return;
200
+ }
195
201
 
196
202
  const urlMatch = window.location.pathname.match(/\/chats\/(\d+)/);
197
203
  const urlRoomId = urlMatch ? parseInt(urlMatch[1], 10) : 0;