mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-13 18:50:29 +03:00
Improve search result counts (#2221)
* remove limit from emoji autocomplete * remove search limit from user mention * remove limit from room mention autocomplete * increase user search limit to 1000 * better search string selection for emoticons
This commit is contained in:
parent
3ada21a1df
commit
1b200eb676
6 changed files with 53 additions and 40 deletions
|
|
@ -6,11 +6,7 @@ import { Room } from 'matrix-js-sdk';
|
|||
import { AutocompleteQuery } from './autocompleteQuery';
|
||||
import { AutocompleteMenu } from './AutocompleteMenu';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import {
|
||||
SearchItemStrGetter,
|
||||
UseAsyncSearchOptions,
|
||||
useAsyncSearch,
|
||||
} from '../../../hooks/useAsyncSearch';
|
||||
import { UseAsyncSearchOptions, useAsyncSearch } from '../../../hooks/useAsyncSearch';
|
||||
import { onTabPress } from '../../../utils/keyboard';
|
||||
import { createEmoticonElement, moveCursor, replaceWithElement } from '../utils';
|
||||
import { useRecentEmoji } from '../../../hooks/useRecentEmoji';
|
||||
|
|
@ -20,6 +16,7 @@ import { useKeyDown } from '../../../hooks/useKeyDown';
|
|||
import { mxcUrlToHttp } from '../../../utils/matrix';
|
||||
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
||||
import { ImageUsage, PackImageReader } from '../../../plugins/custom-emoji';
|
||||
import { getEmoticonSearchStr } from '../../../plugins/utils';
|
||||
|
||||
type EmoticonCompleteHandler = (key: string, shortcode: string) => void;
|
||||
|
||||
|
|
@ -33,16 +30,11 @@ type EmoticonAutocompleteProps = {
|
|||
};
|
||||
|
||||
const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
||||
limit: 20,
|
||||
matchOptions: {
|
||||
contain: true,
|
||||
},
|
||||
};
|
||||
|
||||
const getEmoticonStr: SearchItemStrGetter<EmoticonSearchItem> = (emoticon) => [
|
||||
`:${emoticon.shortcode}:`,
|
||||
];
|
||||
|
||||
export function EmoticonAutocomplete({
|
||||
imagePackRooms,
|
||||
editor,
|
||||
|
|
@ -63,8 +55,12 @@ export function EmoticonAutocomplete({
|
|||
);
|
||||
}, [imagePacks]);
|
||||
|
||||
const [result, search, resetSearch] = useAsyncSearch(searchList, getEmoticonStr, SEARCH_OPTIONS);
|
||||
const autoCompleteEmoticon = result ? result.items : recentEmoji;
|
||||
const [result, search, resetSearch] = useAsyncSearch(
|
||||
searchList,
|
||||
getEmoticonSearchStr,
|
||||
SEARCH_OPTIONS
|
||||
);
|
||||
const autoCompleteEmoticon = result ? result.items.slice(0, 20) : recentEmoji;
|
||||
|
||||
useEffect(() => {
|
||||
if (query.text) search(query.text);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ type RoomMentionAutocompleteProps = {
|
|||
};
|
||||
|
||||
const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
||||
limit: 20,
|
||||
matchOptions: {
|
||||
contain: true,
|
||||
},
|
||||
|
|
@ -97,7 +96,7 @@ export function RoomMentionAutocomplete({
|
|||
SEARCH_OPTIONS
|
||||
);
|
||||
|
||||
const autoCompleteRoomIds = result ? result.items : allRooms.slice(0, 20);
|
||||
const autoCompleteRoomIds = result ? result.items.slice(0, 20) : allRooms.slice(0, 20);
|
||||
|
||||
useEffect(() => {
|
||||
if (query.text) search(query.text);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ const withAllowedMembership = (member: RoomMember): boolean =>
|
|||
member.membership === Membership.Knock;
|
||||
|
||||
const SEARCH_OPTIONS: UseAsyncSearchOptions = {
|
||||
limit: 20,
|
||||
limit: 1000,
|
||||
matchOptions: {
|
||||
contain: true,
|
||||
},
|
||||
|
|
@ -97,7 +97,7 @@ export function UserMentionAutocomplete({
|
|||
const members = useRoomMembers(mx, roomId);
|
||||
|
||||
const [result, search, resetSearch] = useAsyncSearch(members, getRoomMemberStr, SEARCH_OPTIONS);
|
||||
const autoCompleteMembers = (result ? result.items : members.slice(0, 20)).filter(
|
||||
const autoCompleteMembers = (result ? result.items.slice(0, 20) : members.slice(0, 20)).filter(
|
||||
withAllowedMembership
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue