Skip to content

Commit

Permalink
fix: reload experiment after default template update
Browse files Browse the repository at this point in the history
The reload of the experiment was done in the wrong place. Sometimes the experiment template id subject signaled an update before the templateId was updated.
  • Loading branch information
infacc committed Aug 2, 2023
1 parent 3445eab commit d917a68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/app/components/experiment/experiment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,11 @@ export class ExperimentComponent implements OnInit, OnDestroy {
});
}

async updateExperimentDefaultTemplate(templateId: string | null) {
updateExperimentDefaultTemplate(templateId: string | null) {
if (this.experimentId == null) {
console.warn("Experiment ID is null!");
return;
}
await this.templates.setExperimentDefaultTemplate(this.experimentId, templateId);
this.experimentService.reloadExperiment();
this.templates.setExperimentDefaultTemplate(this.experimentId, templateId);
}
}
3 changes: 2 additions & 1 deletion src/app/services/templates.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ export class TemplatesService {
return templateResponse?.data?.groups ?? [];
}

async setExperimentDefaultTemplate(experimentId: string, templateId: string | null) {
setExperimentDefaultTemplate(experimentId: string, templateId: string | null) {
this.backend.updateExperimentDefaultTemplate(experimentId, templateId).pipe(take(1)).subscribe(
response => {
this.experimentTemplateIdSubject.next(response?.templateId ?? null);
this.currentExperiment.reloadExperiment();
}
);
}
Expand Down

0 comments on commit d917a68

Please sign in to comment.