Fix duplicate requests in picsur-img.component
This is caused by improper initial state (Loading) that triggers `onInview` multiple times.
This commit is contained in:
parent
949b5c95c7
commit
86737ebe6a
|
@ -16,5 +16,5 @@
|
||||||
<mat-spinner
|
<mat-spinner
|
||||||
(nguiInview)="onInview($event)"
|
(nguiInview)="onInview($event)"
|
||||||
(nguiOutview)="onOutview($event)"
|
(nguiOutview)="onOutview($event)"
|
||||||
*ngIf="state === 'loading'"
|
*ngIf="state === 'init' || state === 'loading'"
|
||||||
></mat-spinner>
|
></mat-spinner>
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { Logger } from 'src/app/services/logger/logger.service';
|
||||||
import { QoiWorkerService } from 'src/app/workers/qoi-worker.service';
|
import { QoiWorkerService } from 'src/app/workers/qoi-worker.service';
|
||||||
|
|
||||||
enum PicsurImgState {
|
enum PicsurImgState {
|
||||||
|
Init = 'init',
|
||||||
Loading = 'loading',
|
Loading = 'loading',
|
||||||
Canvas = 'canvas',
|
Canvas = 'canvas',
|
||||||
Image = 'image',
|
Image = 'image',
|
||||||
|
@ -39,7 +40,7 @@ export class PicsurImgComponent implements OnChanges {
|
||||||
|
|
||||||
@Input('src') imageURL: string | undefined;
|
@Input('src') imageURL: string | undefined;
|
||||||
|
|
||||||
public state: PicsurImgState = PicsurImgState.Loading;
|
public state: PicsurImgState = PicsurImgState.Init;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly qoiWorker: QoiWorkerService,
|
private readonly qoiWorker: QoiWorkerService,
|
||||||
|
@ -113,7 +114,8 @@ export class PicsurImgComponent implements OnChanges {
|
||||||
onInview(e: any) {
|
onInview(e: any) {
|
||||||
this.isInView = true;
|
this.isInView = true;
|
||||||
|
|
||||||
if (this.state === PicsurImgState.Loading) {
|
if (this.state === PicsurImgState.Init) {
|
||||||
|
this.state = PicsurImgState.Loading;
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue