Fix bug in room member search
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
abe03811f1
commit
162af35254
1 changed files with 4 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue