Fix wildcard matching in emojisearch (#121)
authorAjay Bura <ajbura@gmail.com>
Mon, 25 Oct 2021 11:16:23 +0000 (16:46 +0530)
committerKrishan <33421343+kfiven@users.noreply.github.com>
Mon, 25 Oct 2021 12:29:57 +0000 (17:59 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/organisms/emoji-board/EmojiBoard.jsx
src/app/organisms/room/RoomViewCmdBar.jsx

index 2cdef537861a4854854923ff5d6aa70704e3244c..05f7395203355dca1e18e3c907dc3b8bcd406400 100644 (file)
@@ -80,7 +80,7 @@ EmojiGroup.propTypes = {
 };
 
 const asyncSearch = new AsyncSearch();
-asyncSearch.setup(emojis, { keys: ['shortcode'], limit: 30 });
+asyncSearch.setup(emojis, { keys: ['shortcode'], isContain: true, limit: 40 });
 function SearchedEmoji() {
   const [searchedEmojis, setSearchedEmojis] = useState(null);
 
index 329d46a5d0d2b0032342e887b2f030d710b3325d..1f632810c7bacdbbfa616f900b79f69f9c55ad79 100644 (file)
@@ -319,6 +319,7 @@ function RoomViewCmdBar({ roomId, roomTimeline, viewEvent }) {
         else if (searchTerm.match(/^[-]?(\()$/)) searchTerm = 'pleading_face';
         else if (searchTerm.match(/^[-]?(\$)$/)) searchTerm = 'money';
         else if (searchTerm.match(/^(<3)$/)) searchTerm = 'heart';
+        else if (searchTerm.match(/^(c|ca|cat)$/)) searchTerm = '_cat';
       }
     }
 
@@ -343,7 +344,7 @@ function RoomViewCmdBar({ roomId, roomTimeline, viewEvent }) {
       '>*': () => asyncSearch.setup(getRooms([...roomList.spaces]), { keys: ['name'], limit: 20 }),
       '>#': () => asyncSearch.setup(getRooms([...roomList.rooms]), { keys: ['name'], limit: 20 }),
       '>@': () => asyncSearch.setup(getRooms([...roomList.directs]), { keys: ['name'], limit: 20 }),
-      ':': () => asyncSearch.setup(emojis, { keys: ['shortcode'], limit: 20 }),
+      ':': () => asyncSearch.setup(emojis, { keys: ['shortcode'], isContain: true, limit: 20 }),
       '@': () => asyncSearch.setup(matrixClient.getRoom(roomId).getJoinedMembers().map((member) => ({
         name: member.name,
         userId: member.userId.slice(1),