Fix: Respect Page-Order in Loading & Memory Eviction (#61, #63, #68)

This commit is contained in:
Youwes09
2026-05-10 02:17:25 -05:00
parent 7b2ae74c02
commit e09ae9d2e7
6 changed files with 320 additions and 110 deletions
+20 -15
View File
@@ -420,23 +420,28 @@
$effect(() => {
const ahead = store.settings.preloadPages ?? 3;
const current = store.pageUrls[store.pageNumber - 1];
const pageNum = store.pageNumber;
const urls = store.pageUrls;
if (!current) return;
if (useBlob) {
import("@core/cache/imageCache").then(({ getBlobUrl, preloadBlobUrls }) => {
getBlobUrl(current, 999);
const upcoming = Array.from({ length: ahead }, (_, i) => store.pageUrls[store.pageNumber + i]).filter(Boolean) as string[];
const behind = store.pageUrls[store.pageNumber - 2];
preloadBlobUrls(upcoming, ahead);
if (behind) preloadBlobUrls([behind], 0);
});
} else {
for (let i = 1; i <= ahead; i++) {
const url = store.pageUrls[store.pageNumber - 1 + i];
if (url) preloadImage(url, useBlob);
const t = setTimeout(() => {
if (useBlob) {
import("@core/cache/imageCache").then(({ getBlobUrl, preloadBlobUrls }) => {
getBlobUrl(current, 999);
const upcoming = Array.from({ length: ahead }, (_, i) => urls[pageNum + i]).filter(Boolean) as string[];
const behind = urls[pageNum - 2];
preloadBlobUrls(upcoming, ahead);
if (behind) preloadBlobUrls([behind], 0);
});
} else {
for (let i = 1; i <= ahead; i++) {
const url = urls[pageNum - 1 + i];
if (url) preloadImage(url, useBlob);
}
const behind = urls[pageNum - 2];
if (behind) preloadImage(behind, useBlob);
}
const behind = store.pageUrls[store.pageNumber - 2];
if (behind) preloadImage(behind, useBlob);
}
}, 150);
return () => clearTimeout(t);
});
$effect(() => {