perf: Use null matcher when no query

ad88acc9805a14bf67987f9018b9dd83ff906c27

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +2 -1Showing whitespace changes
src/endpoints/chats.js+2 -1
@@ -919,7 +919,8 @@ router.post('/search', validateAvatarUrlMiddleware, async function (request, res
919 };919 };
920920
921 for (const chatFile of chatFiles) {921 for (const chatFile of chatFiles) {
922 const chatInfo = await getChatInfo(chatFile, {}, false, hasTextMatch);922 const matcher = query ? hasTextMatch : null;
923 const chatInfo = await getChatInfo(chatFile, {}, false, matcher);
923 const hasMatch = hasTextMatch(chatInfo.file_id ?? '') || chatInfo.match;924 const hasMatch = hasTextMatch(chatInfo.file_id ?? '') || chatInfo.match;
924925
925 // Skip corrupted or invalid chat files926 // Skip corrupted or invalid chat files