Skip to content

Commit dd85890

Browse files
authored
fix loading history in development (#1102)
1 parent 30f9765 commit dd85890

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/views/workflow-history/hooks/use-workflow-history-fetcher.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default function useWorkflowHistoryFetcher(
2525
) {
2626
const queryClient = useQueryClient();
2727
const fetcherRef = useRef<WorkflowHistoryFetcher | null>(null);
28-
const lastFlattenedPagesCountRef = useRef<number>(-1);
2928

3029
if (!fetcherRef.current) {
3130
fetcherRef.current = new WorkflowHistoryFetcher(queryClient, params);
@@ -46,12 +45,13 @@ export default function useWorkflowHistoryFetcher(
4645

4746
useEffect(() => {
4847
if (!fetcherRef.current) return;
48+
let lastFlattenedPagesCount = -1;
4949
const unsubscribe = fetcherRef.current.onChange((state) => {
5050
const pagesCount = state.data?.pages?.length || 0;
5151
// If the pages count is greater than the last flattened pages count, then we need to flatten the pages and call the onEventsChange callback
5252
// Depending on ref variable instead of historyQuery is because historyQuery is throttled.
53-
if (pagesCount > lastFlattenedPagesCountRef.current) {
54-
lastFlattenedPagesCountRef.current = pagesCount;
53+
if (pagesCount > lastFlattenedPagesCount) {
54+
lastFlattenedPagesCount = pagesCount;
5555
onEventsChange(
5656
state.data?.pages?.flatMap((page) => page.history?.events || []) || []
5757
);

0 commit comments

Comments
 (0)