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
|
||||
(nguiInview)="onInview($event)"
|
||||
(nguiOutview)="onOutview($event)"
|
||||
*ngIf="state === 'loading'"
|
||||
*ngIf="state === 'init' || state === 'loading'"
|
||||
></mat-spinner>
|
||||
|
|
|
@ -17,6 +17,7 @@ import { Logger } from 'src/app/services/logger/logger.service';
|
|||
import { QoiWorkerService } from 'src/app/workers/qoi-worker.service';
|
||||
|
||||
enum PicsurImgState {
|
||||
Init = 'init',
|
||||
Loading = 'loading',
|
||||
Canvas = 'canvas',
|
||||
Image = 'image',
|
||||
|
@ -39,7 +40,7 @@ export class PicsurImgComponent implements OnChanges {
|
|||
|
||||
@Input('src') imageURL: string | undefined;
|
||||
|
||||
public state: PicsurImgState = PicsurImgState.Loading;
|
||||
public state: PicsurImgState = PicsurImgState.Init;
|
||||
|
||||
constructor(
|
||||
private readonly qoiWorker: QoiWorkerService,
|
||||
|
@ -113,7 +114,8 @@ export class PicsurImgComponent implements OnChanges {
|
|||
onInview(e: any) {
|
||||
this.isInView = true;
|
||||
|
||||
if (this.state === PicsurImgState.Loading) {
|
||||
if (this.state === PicsurImgState.Init) {
|
||||
this.state = PicsurImgState.Loading;
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue