Add load newer logic.

pull/255/head
Andrey Dolgolev 2021-09-15 18:10:44 +03:00
rodzic f980c68384
commit 1ca5ce53b8
2 zmienionych plików z 4 dodań i 10 usunięć

Wyświetl plik

@ -465,16 +465,6 @@ const EntriesNavigation = () => {
))}
{previousEvent && !eventsIsFetching ? (
<Center>
<Button
onClick={() => {
setCursor(cursor + PAGE_SIZE);
}}
variant="outline"
colorScheme="suggested"
>
{" "}
Page++{`${cursor}/${streamCache.length}`}
</Button>
<Button
onClick={() => {
console.log(streamCache.length > cursor + PAGE_SIZE);

Wyświetl plik

@ -5,6 +5,7 @@ import { useQuery, useQueryClient } from "react-query";
import { queryCacheProps } from "./hookCommon";
import { defaultStreamBoundary } from "../services/servertime.service.js";
import { PAGE_SIZE } from "../constants";
import { useCounter } from "@chakra-ui/counter";
const useStream = (q, streamCache, setStreamCache, cursor, setCursor) => {
const [streamQuery, setStreamQuery] = useState(q || "");
const [events, setEvents] = useState([]);
@ -208,6 +209,9 @@ const useStream = (q, streamCache, setStreamCache, cursor, setCursor) => {
let oldEventsList = streamCache;
setStreamCache([...newEvents.events, ...oldEventsList]);
if (oldEventsList > 0) {
setCursor(cursor + newEvents.events.length);
}
updateStreamBoundaryWith(newEvents.stream_boundary, {
ignoreStart: true,