[Session View] Empty session fix (#135390)

* fix to handle empty session bug

* fix to handle empty session bug

Co-authored-by: Karl Godard <karlgodard@elastic.co>
This commit is contained in:
Karl Godard 2022-06-29 22:03:00 -07:00 committed by GitHub
parent cff5be9da2
commit 05d4c2b907
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,10 +61,14 @@ export const useFetchSessionViewProcessEvents = (
getNextPageParam: (lastPage, pages) => {
const isRefetch = pages.length === 1 && jumpToCursor;
if (isRefetch || lastPage.events.length >= PROCESS_EVENTS_PER_PAGE) {
return {
cursor: lastPage.events[lastPage.events.length - 1]['@timestamp'],
forward: true,
};
const cursor = lastPage.events?.[lastPage.events.length - 1]?.['@timestamp'];
if (cursor) {
return {
cursor,
forward: true,
};
}
}
},
getPreviousPageParam: (firstPage, pages) => {