Skip to content

Commit

Permalink
fix: Fix data reloading issues (#1277)
Browse files Browse the repository at this point in the history
Co-authored-by: Tiffany K <[email protected]>
  • Loading branch information
minghay and tkyi authored Dec 3, 2024
1 parent 094fc87 commit e3c8914
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 5 additions & 3 deletions app/components/pipeline/workflow/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default class PipelineWorkflowComponent extends Component {

eventType;

dataReloadId;

constructor() {
super(...arguments);

Expand All @@ -64,9 +66,9 @@ export default class PipelineWorkflowComponent extends Component {
: PR_EVENT;

if (this.eventType === PIPELINE_EVENT) {
this.workflowDataReload.start(pipeline.id, false);
this.dataReloadId = this.workflowDataReload.start(pipeline.id, false);
} else {
this.workflowDataReload.start(pipeline.id, true);
this.dataReloadId = this.workflowDataReload.start(pipeline.id, true);
}

if (this.args.noEvents) {
Expand Down Expand Up @@ -110,7 +112,7 @@ export default class PipelineWorkflowComponent extends Component {
willDestroy() {
super.willDestroy();

this.workflowDataReload.stop();
this.workflowDataReload.stop(this.dataReloadId);
}

@action
Expand Down
24 changes: 20 additions & 4 deletions app/workflow-data-reload/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default class WorkflowDataReloadService extends Service {

requiresLatestCommitEvent;

id;

ids;

constructor() {
super(...arguments);

Expand All @@ -22,10 +26,15 @@ export default class WorkflowDataReloadService extends Service {
);
this.buildsReloader = new BuildsDataReloader(this.shuttle);
this.openPrsReloader = new OpenPrsReloader(this.shuttle);

this.id = 0;
this.ids = new Set();
}

start(pipelineId, isPR) {
this.stop();
this.stop(this.id);
this.id += 1;
this.ids.add(this.id);

if (!isPR) {
this.requiresLatestCommitEvent = true;
Expand All @@ -38,11 +47,18 @@ export default class WorkflowDataReloadService extends Service {
}

this.buildsReloader.start();

return this.id;
}

stop() {
this.latestCommitEventReloader.stop();
this.buildsReloader.stop();
stop(id) {
if (this.ids.has(id)) {
this.ids.delete(id);

this.latestCommitEventReloader.stop();
this.openPrsReloader.stop();
this.buildsReloader.stop();
}
}

getBuildsForEvent(eventId) {
Expand Down

0 comments on commit e3c8914

Please sign in to comment.