Chat titles are now included in the search. Query terms don't have to occur in the same message anymore.

35fa634f1d354c6c9d7629734f72256cc0cdc738

Gness Erquint <gness.na@gmail.com>

1 files changed, +4 -5Ignore whitespace
src/endpoints/chats.js+4 -5
@@ -783,12 +783,11 @@ router.post('/search', validateAvatarUrlMiddleware, function (request, response)
783 continue;783 continue;
784 }784 }
785785
786 // Search through messages786 // Search through chats
787 const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x);787 const fragments = query.trim().toLowerCase().split(/\s+/).filter(x => x);
788 const hasMatch = messages.some(message => {788 const text = messages.map(message => message?.mes).join('').toLowerCase();
789 const text = message?.mes?.toLowerCase();789 const stem = chatFile.path.toLowerCase().split(/[\\\/]/).pop().replace(/.jsonl$/, '');
790 return text && fragments.every(fragment => text.includes(fragment));790 const hasMatch = fragments.every(fragment => (stem + text).includes(fragment));
791 });
792791
793 if (hasMatch) {792 if (hasMatch) {
794 results.push({793 results.push({