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];
|
return [members];
|
||||||
}
|
}
|
||||||
|
|
||||||
const asyncSearch = new AsyncSearch();
|
|
||||||
function useSearchMembers(members) {
|
function useSearchMembers(members) {
|
||||||
const [searchMembers, setSearchMembers] = useState(null);
|
const [searchMembers, setSearchMembers] = useState(null);
|
||||||
|
const [asyncSearch] = useState(new AsyncSearch());
|
||||||
|
|
||||||
const reSearch = useCallback(() => {
|
const reSearch = useCallback(() => {
|
||||||
if (searchMembers) {
|
if (searchMembers) {
|
||||||
asyncSearch.search(searchMembers.term);
|
asyncSearch.search(searchMembers.term);
|
||||||
}
|
}
|
||||||
}, [searchMembers]);
|
}, [searchMembers, asyncSearch]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
asyncSearch.setup(members, {
|
asyncSearch.setup(members, {
|
||||||
|
@ -100,7 +100,7 @@ function useSearchMembers(members) {
|
||||||
limit: PER_PAGE_MEMBER,
|
limit: PER_PAGE_MEMBER,
|
||||||
});
|
});
|
||||||
reSearch();
|
reSearch();
|
||||||
}, [members]);
|
}, [members, asyncSearch]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleSearchData = (data, term) => setSearchMembers({ data, term });
|
const handleSearchData = (data, term) => setSearchMembers({ data, term });
|
||||||
|
@ -108,7 +108,7 @@ function useSearchMembers(members) {
|
||||||
return () => {
|
return () => {
|
||||||
asyncSearch.removeListener(asyncSearch.RESULT_SENT, handleSearchData);
|
asyncSearch.removeListener(asyncSearch.RESULT_SENT, handleSearchData);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [asyncSearch]);
|
||||||
|
|
||||||
const handleSearch = (e) => {
|
const handleSearch = (e) => {
|
||||||
const term = e.target.value;
|
const term = e.target.value;
|
||||||
|
|
Loading…
Reference in a new issue