mirror of
https://github.com/moku-project/Moku.git
synced 2026-06-13 01:09:56 -05:00
Fix: Attempt to fix Reader Page-Misfiring Bug & Optimize Loading (Auth Only)
This commit is contained in:
@@ -31,7 +31,14 @@ In-Progress:
|
||||
- Enable Cloudflare Bypass (Suwayomi Config) (Requires Patching)
|
||||
|
||||
- Working on 3D Display Cards
|
||||
- Chapter refresh Notification Looks bad (Series Detail)
|
||||
|
||||
- Fix Discover Workout
|
||||
- Fix CSS on Saved State for Search
|
||||
- Fix State & Cache names (Mapped to Discover hence needs Renaming)
|
||||
- Completely Remove Discover
|
||||
|
||||
- Add Small QOL Animations where Appropriate
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -642,8 +642,8 @@
|
||||
if (style === "double" && pageGroups.length) { advanceGroup(true); return; }
|
||||
if (!store.pageUrls.length) return;
|
||||
if (store.pageNumber < lastPage) {
|
||||
if (style === "fade") { animateFade(() => { store.pageNumber++; }); }
|
||||
else { store.pageNumber++; }
|
||||
if (style === "fade") { animateFade(() => { store.pageNumber = Math.min(lastPage, store.pageNumber + pageStep); }); }
|
||||
else { store.pageNumber = Math.min(lastPage, store.pageNumber + pageStep); }
|
||||
} else if (adjacent.next) {
|
||||
maybeMarkCurrentRead();
|
||||
store.pageNumber = 1;
|
||||
@@ -660,11 +660,13 @@
|
||||
if (style === "double" && pageGroups.length) { advanceGroup(false); return; }
|
||||
if (!store.pageUrls.length) return;
|
||||
if (store.pageNumber > 1) {
|
||||
if (style === "fade") { animateFade(() => { store.pageNumber--; }); }
|
||||
else { store.pageNumber--; }
|
||||
if (style === "fade") { animateFade(() => { store.pageNumber = Math.max(1, store.pageNumber - pageStep); }); }
|
||||
else { store.pageNumber = Math.max(1, store.pageNumber - pageStep); }
|
||||
} else if (adjacent.prev) { startAtLastPage = true; openReader(adjacent.prev, store.activeChapterList); }
|
||||
}
|
||||
|
||||
const pageStep = $derived(style === "double" ? 2 : 1);
|
||||
|
||||
const goNext = $derived(rtl ? goBack : goForward);
|
||||
const goPrev = $derived(rtl ? goForward : goBack);
|
||||
|
||||
@@ -1019,11 +1021,11 @@
|
||||
<button class="mode-btn" class:active={autoNext} onclick={() => updateSettings({ autoNextChapter: !autoNext })}>
|
||||
<span class="mode-label">Auto</span>
|
||||
</button>
|
||||
{/if}
|
||||
{#if !autoNext}
|
||||
<button class="mode-btn" class:active={markOnNext} onclick={() => updateSettings({ markReadOnNext: !markOnNext })}>
|
||||
<span class="mode-label">Mk.Read</span>
|
||||
</button>
|
||||
{#if !autoNext}
|
||||
<button class="mode-btn" class:active={markOnNext} onclick={() => updateSettings({ markReadOnNext: !markOnNext })}>
|
||||
<span class="mode-label">Mk.Read</span>
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
|
||||
+18
-5
@@ -4,7 +4,7 @@ import { store } from "../store/state.svelte";
|
||||
const cache = new Map<string, string>();
|
||||
const inflight = new Map<string, Promise<string>>();
|
||||
|
||||
const MAX_CONCURRENT = 14;
|
||||
const MAX_CONCURRENT = 6;
|
||||
let active = 0;
|
||||
|
||||
interface QueueEntry {
|
||||
@@ -30,9 +30,18 @@ async function doFetch(url: string): Promise<string> {
|
||||
return blobUrl;
|
||||
}
|
||||
|
||||
function insertSorted(entry: QueueEntry) {
|
||||
let lo = 0, hi = queue.length;
|
||||
while (lo < hi) {
|
||||
const mid = (lo + hi) >>> 1;
|
||||
if (queue[mid].priority > entry.priority) lo = mid + 1;
|
||||
else hi = mid;
|
||||
}
|
||||
queue.splice(lo, 0, entry);
|
||||
}
|
||||
|
||||
function drain() {
|
||||
while (active < MAX_CONCURRENT && queue.length > 0) {
|
||||
queue.sort((a, b) => b.priority - a.priority);
|
||||
const entry = queue.shift()!;
|
||||
active++;
|
||||
doFetch(entry.url)
|
||||
@@ -47,7 +56,7 @@ function drain() {
|
||||
|
||||
function enqueue(url: string, priority: number): Promise<string> {
|
||||
const promise = new Promise<string>((resolve, reject) => {
|
||||
queue.push({ url, priority, resolve, reject });
|
||||
insertSorted({ url, priority, resolve, reject });
|
||||
});
|
||||
inflight.set(url, promise);
|
||||
drain();
|
||||
@@ -62,8 +71,12 @@ export function getBlobUrl(url: string, priority = 0): Promise<string> {
|
||||
|
||||
const existing = inflight.get(url);
|
||||
if (existing) {
|
||||
const entry = queue.find(e => e.url === url);
|
||||
if (entry && priority > entry.priority) entry.priority = priority;
|
||||
const idx = queue.findIndex(e => e.url === url);
|
||||
if (idx !== -1 && priority > queue[idx].priority) {
|
||||
const [entry] = queue.splice(idx, 1);
|
||||
entry.priority = priority;
|
||||
insertSorted(entry);
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user