perf: Improve performance of rendering context menus
This commit is contained in:
@@ -13,8 +13,8 @@ import PaginatedList from "~/components/PaginatedList";
|
||||
import Text from "~/components/Text";
|
||||
import useBoolean from "~/hooks/useBoolean";
|
||||
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
||||
import useDebouncedCallback from "~/hooks/useDebouncedCallback";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import useThrottledCallback from "~/hooks/useThrottledCallback";
|
||||
import useToasts from "~/hooks/useToasts";
|
||||
import MemberListItem from "./components/MemberListItem";
|
||||
|
||||
@@ -31,12 +31,7 @@ function AddPeopleToCollection({ collection }: Props) {
|
||||
useBoolean();
|
||||
const [query, setQuery] = React.useState("");
|
||||
|
||||
const handleFilter = (ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setQuery(ev.target.value);
|
||||
debouncedFetch(ev.target.value);
|
||||
};
|
||||
|
||||
const debouncedFetch = useDebouncedCallback(
|
||||
const debouncedFetch = useThrottledCallback(
|
||||
(query) =>
|
||||
users.fetchPage({
|
||||
query,
|
||||
@@ -44,6 +39,11 @@ function AddPeopleToCollection({ collection }: Props) {
|
||||
250
|
||||
);
|
||||
|
||||
const handleFilter = (ev: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setQuery(ev.target.value);
|
||||
void debouncedFetch(ev.target.value);
|
||||
};
|
||||
|
||||
const handleAddUser = async (user: User) => {
|
||||
try {
|
||||
await memberships.create({
|
||||
|
||||
Reference in New Issue
Block a user