Feat: Automated Tracking + Proper Sync

This commit is contained in:
Youwes09
2026-04-26 12:11:45 -05:00
parent 361a145702
commit c0efbba4df
8 changed files with 358 additions and 64 deletions
+4 -1
View File
@@ -3,6 +3,7 @@ import { store, addHistory, addBookmark, removeBookmark,
checkAndMarkCompleted, DEFAULT_MANGA_PREFS } from "@store/state.svelte";
import { MARK_CHAPTER_READ, DELETE_DOWNLOADED_CHAPTERS } from "@api/mutations/chapters";
import { ENQUEUE_CHAPTERS_DOWNLOAD } from "@api/mutations/downloads";
import { trackingState } from "@features/tracking/store/trackingState.svelte";
const AVG_MIN_PER_PAGE = 0.33;
@@ -30,6 +31,8 @@ export function markChapterRead(id: number, markedRead: Set<number>) {
if (!mangaId) return;
const updated = store.activeChapterList.map(c => c.id === id ? { ...c, isRead: true } : c);
checkAndMarkCompleted(mangaId, updated);
const ch = store.activeChapterList.find(c => c.id === id) ?? store.activeChapter;
if (ch) trackingState.updateFromRead(ch, store.activeChapterList, getMangaPrefs());
const prefs = getMangaPrefs();
if (prefs.deleteOnRead) {
const ch = store.activeChapterList.find(c => c.id === id);
@@ -73,4 +76,4 @@ export function toggleBookmark(
if (existing) removeBookmark(existing.chapterId);
addBookmark({ mangaId: manga.id, mangaTitle: manga.title, thumbnailUrl: manga.thumbnailUrl, chapterId: ch.id, chapterName: ch.name, pageNumber });
}
}
}
+4
View File
@@ -1,6 +1,7 @@
import { store, openReader } from "@store/state.svelte";
import { readerState } from "../store/readerState.svelte";
import { fetchPages } from "./pageLoader";
import { trackingState } from "@features/tracking/store/trackingState.svelte";
export function scheduleResumeDismiss() {
setTimeout(() => { readerState.resumeFading = true; }, 1500);
@@ -23,6 +24,9 @@ export async function loadChapter(
readerState.resetForChapter();
store.pageUrls = [];
const mangaId = store.activeManga?.id;
if (mangaId) trackingState.loadForManga(mangaId);
const bookmark = store.bookmarks.find(b => b.chapterId === id);
const resumeTo = bookmark ? bookmark.pageNumber : 0;
readerState.resumePage = resumeTo > 1 ? resumeTo : 0;