1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: Pagination of event log (#2495)

Currently, our event log is keeping all the previous data and then
fetching and appending to our state list. This causes duplicates, since
we're keeping the existing list and might be getting the same data, but
with added events at the end.

This fix changes the logic to slice existing data at offset. Which
should make sure we only append the new data.

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>

Co-authored-by: Fredrik Strand Oseberg <fredrik.no@gmail.com>
This commit is contained in:
Christopher Kolstad 2022-11-22 13:58:08 +01:00 committed by GitHub
parent 8af64e9370
commit a19cd9f2ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,10 @@ export const useEventSearch = (
// Append results to the page when more data has been fetched.
useEffect(() => {
if (data) {
setEvents(prev => [...(prev ?? []), ...data.events]);
setEvents(prev => [
...(prev?.slice(0, offset) || []),
...data.events,
]);
if (data.totalEvents) {
setTotalEvents(data.totalEvents);
}