Skip to content

Commit

Permalink
Fix Search Chat again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashank999 committed Dec 29, 2023
1 parent 4c60ae5 commit 4aa042f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

function addAutocomplete(chat) {
const messages = chat.findAll("[class*='chat-box-body__'] [class*='chat-box-message-']");
const messages = chat.findAll("[class*='chat-box-body__'] [class*='chat-box-message__box__']");
if (!messages.length) return;

const textarea = chat.find("textarea:not(.tt-chat-autocomplete)");
Expand All @@ -55,7 +55,7 @@

if (currentSearchValue === null) currentSearchValue = searchValueMatch[2].toLowerCase();

const matchedUsernames = [...chat.findAll("[class*='chat-box-message-'] [class*='chat-box-message__sender__']")]
const matchedUsernames = [...chat.findAll("[class*='chat-box-message__sender__']")]
.map((message) => message.textContent.split(":")[0])
.filter((username, index, array) => array.indexOf(username) === index && username.toLowerCase().startsWith(currentSearchValue))
.sort();
Expand Down
12 changes: 6 additions & 6 deletions extension/scripts/features/search-chat/ttSearchChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if (!input) return;

const inputValue = input.value;
if (inputValue) searchChat(message.find("[class*='chat-box-message-']"), inputValue);
if (inputValue) searchChat(message.find("[class*='chat-box-message__box__']"), inputValue);
});
CUSTOM_LISTENERS[EVENT_CHANNELS.CHAT_REFRESHED].push(() => {
if (!feature.enabled()) return;
Expand Down Expand Up @@ -147,7 +147,7 @@
function onChatSearch(event, chat) {
const keyword = event.target.value.toLowerCase();

for (const message of chat.findAll("[class*='chat-box-body__'] [class*='chat-box-message-']")) {
for (const message of chat.findAll("[class*='chat-box-body__'] [class*='chat-box-message__box__']")) {
searchChat(message, keyword);
}

Expand All @@ -159,7 +159,7 @@

function removeSearch() {
for (const chat of document.findAll("#chatRoot [class*='group-chat-box__'] [class*='group-chat-box__chat-box-wrapper__']")) {
for (const message of chat.findAll("[class*='chat-box-body__'] [class*='chat-box-message-'] div[class='tt-hidden']")) {
for (const message of chat.findAll("[class*='chat-box-body__'] [class*='chat-box-message__box__'] div[class='tt-hidden']")) {
message.classList.remove("tt-hidden");
}
const chatBody = chat.find("[class*='chat-box-body__']");
Expand All @@ -181,16 +181,16 @@

const sender = message.find("[class*='chat-box-message__sender__']");
if (!sender.textContent.toLowerCase().includes(target) && (isNaN(target) || !sender.href.match(`XID=${target}$`))) {
message.classList.add("tt-hidden");
message.closest("[class*='chat-box-message___']").classList.add("tt-hidden");
return;
}
}

const messageText = message.find("p").textContent.toLowerCase();
if (keyword && !messageText.includes(keyword)) {
message.classList.add("tt-hidden");
message.closest("[class*='chat-box-message___']").classList.add("tt-hidden");
} else {
message.classList.remove("tt-hidden");
message.closest("[class*='chat-box-message___']").classList.remove("tt-hidden");
}
}
})();

0 comments on commit 4aa042f

Please sign in to comment.