Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fetcher start update
  • Loading branch information
Assem-Uber committed Nov 20, 2025
commit 3398d8ae83520ae861f707f5f23ab12e14c9e6bc
12 changes: 7 additions & 5 deletions src/views/workflow-history/helpers/workflow-history-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ export default class WorkflowHistoryFetcher {
if (shouldContinue) {
this.shouldContinue = shouldContinue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if start is called twice?

  1. start( shouldContinue )
  2. start( null )

It appears that the 2nd start would retain the prior shouldContinue. Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% correct. You've just reminded me that i thought about it and forgot to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But to put more context, it is not an issue.
Null is not allowed as an argument and undefined would use the default method. It just doesn't make sense to keep the condition.

}
// If already started, return
if (this.isStarted) return;

// remove current listener (if exists) to have fresh emits only
this.unsubscribe?.();
this.unsubscribe = null;

this.isStarted = true;
let emitCount = 0;
const currentState = this.observer.getCurrentResult();
const fetchedFirstPage = currentState.status !== 'pending';
const shouldEnableQuery = !fetchedFirstPage && shouldContinue(currentState);
const shouldEnableQuery =
!fetchedFirstPage && this.shouldContinue(currentState);

if (shouldEnableQuery) {
this.observer.setOptions({
Expand Down Expand Up @@ -86,8 +90,6 @@ export default class WorkflowHistoryFetcher {
emit(currentState);
}

// remove current listener (if exists) and add new one
this.unsubscribe?.();
this.unsubscribe = this.observer.subscribe((res) => emit(res));
}

Expand Down