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:
parent
8af64e9370
commit
a19cd9f2ae
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user