Skip to content

Node.js based forum software built for the modern web

fix: #14202

Barış Soner Uşaklı4f71a0e7be78
diff --git a/public/language/en-GB/modules.json b/public/language/en-GB/modules.json
index 44e435ae33..48ca552d65 100644
--- a/public/language/en-GB/modules.json
+++ b/public/language/en-GB/modules.json
@@ -41,6 +41,7 @@
"chat.public-rooms": "Public Rooms (%1)",
"chat.private-rooms": "Private Rooms (%1)",
"chat.create-room": "Create Chat Room",
+ "chat.search-chats-placeholder": "Search chats...",
"chat.private.option": "Private (Only visible to users added to room)",
"chat.public.option": "Public (Visible to every user in selected groups)",
"chat.public.groups-help": "To create a chat room that is visible to all users select registered-users from the group list.",
diff --git a/public/src/client/chats/search.js b/public/src/client/chats/search.js
index 9dc1655896..40053c0428 100644
--- a/public/src/client/chats/search.js
+++ b/public/src/client/chats/search.js
@@ -5,20 +5,11 @@ import { get } from 'api';
export function init(searchEl, listEl) {
if (!searchEl || !listEl) {
console.warn('[chats/search] Search element not found');
+ return;
}
- // Debounce function to limit how often the keyup handler fires
- const debounce = (func, delay) => {
- let timeoutId;
- return function (...args) {
- clearTimeout(timeoutId);
- timeoutId = setTimeout(() => func.apply(this, args), delay);
- };
- };
-
- searchEl.addEventListener('keyup', debounce(async function (e) {
+ searchEl.addEventListener('keyup', utils.debounce(async function (e) {
const data = await get(`/chats/search?query=${e.target.value}`);
- console.log(data);
const html = await app.parseAndTranslate('chats', 'rooms', data);
$(listEl).html(html);
}, 300));
diff --git a/src/messaging/index.js b/src/messaging/index.js
index b6044821a9..0500cdf95a 100644
--- a/src/messaging/index.js
+++ b/src/messaging/index.js
@@ -229,6 +229,8 @@ Messaging.searchRecentChats = async (callerUid, uid, query) => {
settings: user.getSettings(uid),
});
+ results.roomData = await modifyChatRooms(uid, results);
+
// Filter rooms based on query
results.roomData = results.roomData
.filter((room, idx) => {
@@ -247,8 +249,6 @@ Messaging.searchRecentChats = async (callerUid, uid, query) => {
return titleMatch || usernameMatch;
});
- results.roomData = await modifyChatRooms(uid, results);
-
return await plugins.hooks.fire('filter:messaging.searchRecentChats', {
rooms: results.roomData,
uid: uid,
diff --git a/src/views/chats.tpl b/src/views/chats.tpl
index 5ad174f8dd..93ad8d2e29 100644
--- a/src/views/chats.tpl
+++ b/src/views/chats.tpl
@@ -3,9 +3,9 @@
<div class="chats-full d-flex gap-1 h-100 mt-3 mt-md-0 py-md-3">
<div component="chat/nav-wrapper" class="flex-shrink-0 d-flex flex-column h-100 gap-1" data-loaded="{{{ if roomId }}}1{{{ else }}}0{{{ end }}}">
- <div class="d-flex flex-column">
+ <div class="d-flex flex-column gap-2">
<button component="chat/create" class="btn btn-primary btn-sm w-100">[[modules:chat.create-room]]</button>
- <input id="search-chats" class="form-control mt-2" type="text" placeholder="Search chats..." />
+ <input id="search-chats" class="form-control form-control-sm" type="text" placeholder="[[modules:chat.search-chats-placeholder]]" />
</div>
{{{ if publicRooms.length }}}