kopia lustrzana https://github.com/bugout-dev/moonstream
Add load newer logic.
rodzic
f980c68384
commit
1ca5ce53b8
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue