Fix bug in room member search

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-01-30 18:57:15 +05:30
parent abe03811f1
commit 162af35254

View file

@ -84,15 +84,15 @@ function useMemberOfMembership(roomId, membership) {
return [members];
}
const asyncSearch = new AsyncSearch();
function useSearchMembers(members) {
const [searchMembers, setSearchMembers] = useState(null);
const [asyncSearch] = useState(new AsyncSearch());
const reSearch = useCallback(() => {
if (searchMembers) {
asyncSearch.search(searchMembers.term);
}
}, [searchMembers]);
}, [searchMembers, asyncSearch]);
useEffect(() => {
asyncSearch.setup(members, {
@ -100,7 +100,7 @@ function useSearchMembers(members) {
limit: PER_PAGE_MEMBER,
});
reSearch();
}, [members]);
}, [members, asyncSearch]);
useEffect(() => {
const handleSearchData = (data, term) => setSearchMembers({ data, term });
@ -108,7 +108,7 @@ function useSearchMembers(members) {
return () => {
asyncSearch.removeListener(asyncSearch.RESULT_SENT, handleSearchData);
};
}, []);
}, [asyncSearch]);
const handleSearch = (e) => {
const term = e.target.value;