Skip to content
Snippets Groups Projects
Commit 8a686f82 authored by jojohoch's avatar jojohoch
Browse files

[player] Fix Geogebra loading timeout

parent cb2b98f6
No related branches found
No related tags found
No related merge requests found
Pipeline #67787 failed
......@@ -23,7 +23,7 @@ declare const GGBApplet: any;
{{ 'geometry_reset' | translate }}
</button>
<div [id]="elementModel.id" class="geogebra-applet"></div>
<aspect-spinner [isLoaded]="isLoaded"
<aspect-spinner *ngIf="isGeoGebraLoaded" [isLoaded]="isLoaded"
(timeOut)="throwError('geometry-timeout', 'Failed to load geometry in time')">
</aspect-spinner>
`,
......@@ -40,6 +40,7 @@ export class GeometryComponent extends ElementComponent implements AfterViewInit
@Output() elementValueChanged = new EventEmitter<ValueChangeElement>();
isLoaded: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
isGeoGebraLoaded: boolean = false;
geoGebraAPI!: any;
private ngUnsubscribe = new Subject<void>();
......@@ -83,6 +84,7 @@ export class GeometryComponent extends ElementComponent implements AfterViewInit
this.externalResourceService.isGeoGebraLoaded()
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((isGeoGebraLoaded: boolean) => {
this.isGeoGebraLoaded = isGeoGebraLoaded;
if (isGeoGebraLoaded) this.initApplet();
});
}
......
......@@ -23,15 +23,13 @@ export class SpinnerComponent implements OnInit, OnDestroy {
constructor(private changeDetectionRef: ChangeDetectorRef) {}
ngOnInit(): void {
this.timeOutId = window.setTimeout(() => this.sendTimeOut(), this.timeOutDuration);
this.isLoaded
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(isLoaded => {
if (isLoaded) {
if (this.timeOutId) clearTimeout(this.timeOutId);
this.isLoading = false;
this.changeDetectionRef.detectChanges();
}
if (this.timeOutId) clearTimeout(this.timeOutId);
if (!isLoaded) this.timeOutId = window.setTimeout(() => this.sendTimeOut(), this.timeOutDuration);
this.isLoading = !isLoaded;
this.changeDetectionRef.detectChanges();
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment