From ce0f16d58b63d1530e98c87625ad34c94692bb7e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 28 Sep 2021 13:52:30 +0100 Subject: [PATCH 1/2] Fix pagination when filtering space hierarchy --- src/components/structures/SpaceHierarchy.tsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/components/structures/SpaceHierarchy.tsx b/src/components/structures/SpaceHierarchy.tsx index db16011917..5d38cc16c2 100644 --- a/src/components/structures/SpaceHierarchy.tsx +++ b/src/components/structures/SpaceHierarchy.tsx @@ -446,7 +446,7 @@ export const useSpaceSummary = (space: Room): { })); const loadMore = useCallback(async (pageSize?: number) => { - if (!hierarchy.canLoadMore || hierarchy.noSupport) return; + if (loading || !hierarchy.canLoadMore || hierarchy.noSupport) return; setLoading(true); await hierarchy.load(pageSize); @@ -648,8 +648,6 @@ const SpaceHierarchy = ({ return { ({ onKeyDownHandler }) => { let content: JSX.Element; - let loader: JSX.Element; - if (loading && !rooms.length) { content = ; } else { @@ -671,19 +669,20 @@ const SpaceHierarchy = ({ }} /> ; - - if (hierarchy.canLoadMore) { - loader =
- -
; - } - } else { + } else if (!hierarchy.canLoadMore) { results =

{ _t("No results found") }

{ _t("You may want to try a different search or check for typos.") }
; } + let loader: JSX.Element; + if (hierarchy.canLoadMore) { + loader =
+ +
; + } + content = <>

{ query.trim() ? _t("Results") : _t("Rooms and spaces") }

From 7f63f496be54326b299fe971156ddd1d858883d8 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 28 Sep 2021 14:03:41 +0100 Subject: [PATCH 2/2] delint --- src/components/structures/SpaceHierarchy.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/SpaceHierarchy.tsx b/src/components/structures/SpaceHierarchy.tsx index 5d38cc16c2..ed87b04c8a 100644 --- a/src/components/structures/SpaceHierarchy.tsx +++ b/src/components/structures/SpaceHierarchy.tsx @@ -452,7 +452,7 @@ export const useSpaceSummary = (space: Room): { await hierarchy.load(pageSize); setRooms(hierarchy.rooms); setLoading(false); - }, [hierarchy]); + }, [loading, hierarchy]); return { loading, rooms, hierarchy, loadMore }; };