Fixed an issue where pages could be skipped in single due to prefetching overriding our recently set image (#1391)

This commit is contained in:
Joseph Milazzo 2022-07-27 16:06:22 -05:00 committed by GitHub
parent 2636dd7919
commit 58fb0d46b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1070,7 +1070,7 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
if (this.layoutMode === LayoutMode.Single) { if (this.layoutMode === LayoutMode.Single) {
const img = this.cachedImages.arr.find(img => this.readerService.imageUrlToPageNum(img.src) === this.pageNum); const img = this.cachedImages.arr.find(img => this.readerService.imageUrlToPageNum(img.src) === this.pageNum);
if (img) { if (img) {
this.canvasImage = img; // If we tried to use this for double, then the src might change after being set (idk how tho) this.canvasImage = img; // If we tried to use this for double, then the loadPage might not render correctly when switching layout mode
} else { } else {
this.canvasImage.src = this.getPageUrl(this.pageNum); this.canvasImage.src = this.getPageUrl(this.pageNum);
} }
@ -1297,14 +1297,15 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
prefetch() { prefetch() {
let index = 1; let index = 1;
this.cachedImages.applyFor((item, internalIndex) => { this.cachedImages.applyFor((item, _) => {
const offsetIndex = this.pageNum + index; const offsetIndex = this.pageNum + index;
const urlPageNum = this.readerService.imageUrlToPageNum(item.src); const urlPageNum = this.readerService.imageUrlToPageNum(item.src);
if (urlPageNum === offsetIndex) { if (urlPageNum === offsetIndex || urlPageNum === this.pageNum) {
index += 1; index += 1;
return; return;
} }
if (offsetIndex < this.maxPages - 1) { if (offsetIndex < this.maxPages - 1) {
item.src = this.getPageUrl(offsetIndex); item.src = this.getPageUrl(offsetIndex);
index += 1; index += 1;