diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-06-10 16:02:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-10 17:02:57 +0200 |
commit | fd03ea3fe1d4f3c6a4079272b0dbd21c4e0d2b1b (patch) | |
tree | a558da31f0d29eb5920baa8810e3bd8340392c4e /src | |
parent | 1317d881ed2f583a65bffeb835b2d57670cce235 (diff) | |
download | voidsky-fd03ea3fe1d4f3c6a4079272b0dbd21c4e0d2b1b.tar.zst |
Throttle instead of debounce (#4456)
* throttle instead of debounce * trailing: true * Fix throttle call --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/state/queries/messages/list-converations.tsx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/state/queries/messages/list-converations.tsx b/src/state/queries/messages/list-converations.tsx index 306d4cae5..eeab246ab 100644 --- a/src/state/queries/messages/list-converations.tsx +++ b/src/state/queries/messages/list-converations.tsx @@ -16,7 +16,7 @@ import { useInfiniteQuery, useQueryClient, } from '@tanstack/react-query' -import debounce from 'lodash.debounce' +import throttle from 'lodash.throttle' import {useCurrentConvoId} from '#/state/messages/current-convo-id' import {useMessagesEventBus} from '#/state/messages/events' @@ -91,7 +91,11 @@ export function ListConvosProviderInner({ const {currentAccount} = useSession() const debouncedRefetch = useMemo( - () => debounce(() => refetch, 500), + () => + throttle(refetch, 500, { + leading: true, + trailing: true, + }), [refetch], ) |