From d82a7f00499efe79ba355fab5361328da607ee82 Mon Sep 17 00:00:00 2001 From: Andrey Dolgolev Date: Tue, 14 Sep 2021 20:11:35 +0300 Subject: [PATCH] Add step fixes. --- frontend/src/components/EntriesNavigation.js | 72 +++++++++++-------- frontend/src/core/constants.js | 2 +- frontend/src/core/hooks/useStream.js | 74 +++++++++++++++----- 3 files changed, 101 insertions(+), 47 deletions(-) diff --git a/frontend/src/components/EntriesNavigation.js b/frontend/src/components/EntriesNavigation.js index d00ccc49..22ec4819 100644 --- a/frontend/src/components/EntriesNavigation.js +++ b/frontend/src/components/EntriesNavigation.js @@ -78,9 +78,9 @@ const EntriesNavigation = () => { ]); const [filterState, setFilterState] = useState([]); const queryClient = useQueryClient(); - console.log(queryClient); const loadMoreButtonRef = useRef(null); - + const [streamCache, setStreamCache] = useState([]); + console.log(streamCache); const { events, eventsIsLoading, @@ -96,7 +96,7 @@ const EntriesNavigation = () => { loadNewerEvents, cursor, setCursor, - } = useStream(ui.searchTerm.q); + } = useStream(ui.searchTerm.q, streamCache, setStreamCache); useEffect(() => { if (!streamBoundary.start_time && !streamBoundary.end_time) { @@ -145,12 +145,18 @@ const EntriesNavigation = () => { } }, [subscriptionsCache, newFilterState, setFilterProps]); - useEffect(() => { - if (cursor >= events.length + 2 * PAGE_SIZE) { - loadOlderEvents(); - previousEventRefetch(); - } - }, [events, cursor]); + // useEffect(() => { + // if (cursor + PAGE_SIZE >= events.length) { + // console.log("Load more"); + // loadOlderEvents(); + // previousEventRefetch(); + // } else if (events.length == 0) { + // console.log("Load more initial"); + // loadOlderEvents(); + // previousEventRefetch(); + // } + // console.log(events.length); + // }, [events, cursor]); const canCreate = false; @@ -473,30 +479,38 @@ const EntriesNavigation = () => {
+