Fix: TrackingSync Excludes Decimals & Respects Chapter Numbers (#63)

This commit is contained in:
Youwes09
2026-05-02 18:14:34 -05:00
parent 3f6049c12d
commit c0f0ff9bd3
+22 -4
View File
@@ -134,6 +134,21 @@ export async function syncBackFromTracker(
scanlatorForce: false, scanlatorForce: false,
}), }),
}); });
const seenInt = new Map<number, Chapter>();
for (const ch of eligible) {
const key = Math.floor(ch.chapterNumber);
if (!Number.isInteger(ch.chapterNumber)) continue;
if (!seenInt.has(key)) seenInt.set(key, ch);
}
const dedupedEligible = [...seenInt.values()];
const decimalsByFloor = new Map<number, Chapter[]>();
for (const ch of eligible) {
if (Number.isInteger(ch.chapterNumber)) continue;
const key = Math.floor(ch.chapterNumber);
const arr = decimalsByFloor.get(key) ?? [];
arr.push(ch);
decimalsByFloor.set(key, arr);
}
const toMarkRead: number[] = []; const toMarkRead: number[] = [];
@@ -141,11 +156,14 @@ export async function syncBackFromTracker(
const remote = record.lastChapterRead; const remote = record.lastChapterRead;
if (!remote || remote <= 0) continue; if (!remote || remote <= 0) continue;
for (const chapter of eligible) { for (const chapter of dedupedEligible) {
if (chapter.isRead) continue; if (chapter.isRead) continue;
const diff = Math.abs(chapter.chapterNumber - remote); if (chapter.chapterNumber > remote) continue;
if (opts.threshold !== null && diff > opts.threshold) continue; if (opts.threshold !== null && remote - chapter.chapterNumber > opts.threshold) continue;
if (chapter.chapterNumber <= remote) toMarkRead.push(chapter.id); toMarkRead.push(chapter.id);
for (const dec of decimalsByFloor.get(chapter.chapterNumber) ?? []) {
if (!dec.isRead) toMarkRead.push(dec.id);
}
} }
} }