fix: set rpc to idle when idle

This commit is contained in:
frozenKelp
2026-06-09 20:13:41 +05:30
parent 22c4a222d8
commit 32bdeb92ff
2 changed files with 15 additions and 2 deletions
+11 -2
View File
@@ -2,7 +2,7 @@
import { onMount, untrack, tick } from "svelte"; import { onMount, untrack, tick } from "svelte";
import { readerState, PAGE_STYLES } from "$lib/state/reader.svelte"; import { readerState, PAGE_STYLES } from "$lib/state/reader.svelte";
import { settingsState, updateSettings } from "$lib/state/settings.svelte"; import { settingsState, updateSettings } from "$lib/state/settings.svelte";
import { app } from "$lib/state/app.svelte"; import { app, appState } from "$lib/state/app.svelte";
import { DEFAULT_KEYBINDS } from "$lib/core/keybinds/defaultBinds"; import { DEFAULT_KEYBINDS } from "$lib/core/keybinds/defaultBinds";
import { fetchPages, resolveUrl, preloadImage, measureAspect, buildPageGroups } from "$lib/components/reader/lib/pageLoader"; import { fetchPages, resolveUrl, preloadImage, measureAspect, buildPageGroups } from "$lib/components/reader/lib/pageLoader";
import { setupScrollTracking, appendNextChapter } from "$lib/components/reader/lib/scrollHandler"; import { setupScrollTracking, appendNextChapter } from "$lib/components/reader/lib/scrollHandler";
@@ -321,11 +321,20 @@
ch.id, ch.name, readerState.pageNumber, ch.id, ch.name, readerState.pageNumber,
); );
loadChapter(ch.id, useBlob, abortCtrl, startAtLastPageRef, markedRead, adjacent); loadChapter(ch.id, useBlob, abortCtrl, startAtLastPageRef, markedRead, adjacent);
setReading(manga, ch).catch(() => {}); // update Discord presence to show current chapter
}); });
} }
}); });
// Separate from chapter load: also re-fires when idle splash dismisses so presence is restored.
$effect(() => {
const ch = readerState.activeChapter;
const manga = readerState.activeManga;
const idle = appState.idleSplash;
if (ch && manga && !idle) {
untrack(() => setReading(manga, ch).catch(() => {}));
}
});
$effect(() => { $effect(() => {
const page = readerState.pageNumber; const page = readerState.pageNumber;
const chId = style === "longstrip" const chId = style === "longstrip"
+4
View File
@@ -154,6 +154,10 @@
if (appState.status === 'ready') resetIdleTimer() if (appState.status === 'ready') resetIdleTimer()
}) })
$effect(() => {
if (appState.idleSplash && settingsState.settings.discordRpc) setIdle().catch(() => {})
})
$effect(() => { $effect(() => {
if (appState.status !== 'ready') return if (appState.status !== 'ready') return
// capture phase so events from any component — including modals — reset the timer // capture phase so events from any component — including modals — reset the timer