From dc7ddeaa9b2f610029dc40c30b203e06f97fab77 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Mon, 25 Oct 2021 16:46:23 +0530 Subject: [PATCH] Fix wildcard matching in emojisearch (#121) Signed-off-by: Ajay Bura --- src/app/organisms/emoji-board/EmojiBoard.jsx | 2 +- src/app/organisms/room/RoomViewCmdBar.jsx | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/organisms/emoji-board/EmojiBoard.jsx b/src/app/organisms/emoji-board/EmojiBoard.jsx index 2cdef53..05f7395 100644 --- a/src/app/organisms/emoji-board/EmojiBoard.jsx +++ b/src/app/organisms/emoji-board/EmojiBoard.jsx @@ -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); diff --git a/src/app/organisms/room/RoomViewCmdBar.jsx b/src/app/organisms/room/RoomViewCmdBar.jsx index 329d46a..1f63281 100644 --- a/src/app/organisms/room/RoomViewCmdBar.jsx +++ b/src/app/organisms/room/RoomViewCmdBar.jsx @@ -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),