Lots of Bugfixes (#2356)

This commit is contained in:
Joe Milazzo 2023-10-27 16:18:56 -05:00 committed by GitHub
parent 86e931dd9a
commit 226d6831df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 359 additions and 225 deletions

View file

@ -103,11 +103,10 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy {
}
ctx.drawImage(img, 0, 0);
const dataURL = canvas.toDataURL("image/png");
return dataURL;
return canvas.toDataURL("image/png");
}
selectImage(index: number) {
selectImage(index: number, callback?: Function) {
if (this.selectedIndex === index) { return; }
// If we load custom images of series/chapters/covers, then those urls are not properly encoded, so on select we have to clean them up
@ -116,7 +115,11 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy {
const img = new Image();
img.crossOrigin = 'Anonymous';
img.src = imgUrl;
img.onload = (e) => this.handleUrlImageAdd(img, index);
img.onload = (e) => {
this.handleUrlImageAdd(img, index);
this.selectedBase64Url.emit(this.imageUrls[this.selectedIndex]);
if (callback) callback(index);
};
img.onerror = (e) => {
this.toastr.error(translate('errors.rejected-cover-upload'));
this.form.get('coverImageUrl')?.setValue('');
@ -124,7 +127,6 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy {
};
this.form.get('coverImageUrl')?.setValue('');
this.cdRef.markForCheck();
this.selectedBase64Url.emit(this.imageUrls[this.selectedIndex]);
return;
}
@ -135,11 +137,13 @@ export class CoverImageChooserComponent implements OnInit, OnDestroy {
}
applyImage(index: number) {
if (this.showApplyButton) {
if (!this.showApplyButton) return;
this.selectImage(index, () => {
this.applyCover.emit(this.imageUrls[index]);
this.appliedIndex = index;
this.cdRef.markForCheck();
}
});
}
resetImage() {