Merge pull request #38 from kaiiiz/patch-dup-reqs

Fix duplicate requests in picsur-img.component
This commit is contained in:
Caramel 2023-03-15 14:11:38 +01:00 committed by GitHub
commit c65b7ca066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -16,5 +16,5 @@
<mat-spinner
(nguiInview)="onInview($event)"
(nguiOutview)="onOutview($event)"
*ngIf="state === 'loading'"
*ngIf="state === 'init' || state === 'loading'"
></mat-spinner>

View File

@ -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();
}
}