1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

pwa fix and dont remove t param after use

This commit is contained in:
mrjvs 2023-10-26 19:53:22 +02:00
parent 92bca33b91
commit df5735cfbf
5 changed files with 17 additions and 12 deletions

View file

@ -109,7 +109,9 @@ function EpisodesView({
const newData = setPlayerMeta(loadingState.value.fullData, episodeId); const newData = setPlayerMeta(loadingState.value.fullData, episodeId);
if (newData) onChange?.(newData); if (newData) onChange?.(newData);
} }
router.close(); // prevent router clear here, otherwise its done double
// player already switches route after meta change
router.close(true);
}, },
[setPlayerMeta, loadingState, router, onChange] [setPlayerMeta, loadingState, router, onChange]
); );

View file

@ -91,10 +91,13 @@ export function useInternalOverlayRouter(id: string) {
return routerActive; return routerActive;
} }
const close = useCallback(() => { const close = useCallback(
if (route) setRoute(null); (preventRouteClear?: boolean) => {
setTransition(null); if (route && !preventRouteClear) setRoute(null);
}, [setRoute, route, setTransition]); setTransition(null);
},
[setRoute, route, setTransition]
);
const open = useCallback( const open = useCallback(
(defaultRoute = "/") => { (defaultRoute = "/") => {

View file

@ -32,7 +32,7 @@ export function useQueryParam(
search: parsed.toString(), search: parsed.toString(),
}); });
}, },
[param, location, router] [param, location.search, router]
); );
return [currentValue, set]; return [currentValue, set];

View file

@ -26,7 +26,7 @@ export function PlayerView() {
sources: Record<string, ScrapingSegment>; sources: Record<string, ScrapingSegment>;
sourceOrder: ScrapingItems[]; sourceOrder: ScrapingItems[];
} | null>(null); } | null>(null);
const [startAtParam, setStartAtParam] = useQueryParam("t"); const [startAtParam] = useQueryParam("t");
const { status, playMedia, reset, setScrapeNotFound } = usePlayer(); const { status, playMedia, reset, setScrapeNotFound } = usePlayer();
const { setPlayerMeta, scrapeMedia } = usePlayerMeta(); const { setPlayerMeta, scrapeMedia } = usePlayerMeta();
const backUrl = useLastNonPlayerLink(); const backUrl = useLastNonPlayerLink();
@ -54,14 +54,13 @@ export function PlayerView() {
const playAfterScrape = useCallback( const playAfterScrape = useCallback(
(out: RunOutput | null) => { (out: RunOutput | null) => {
if (!out) return; if (!out) return;
let startAt: number | undefined; let startAt: number | undefined;
if (startAtParam) { if (startAtParam) startAt = parseTimestamp(startAtParam) ?? undefined;
setStartAtParam(null);
startAt = parseTimestamp(startAtParam) ?? undefined;
}
playMedia(convertRunoutputToSource(out), out.sourceId, startAt); playMedia(convertRunoutputToSource(out), out.sourceId, startAt);
}, },
[playMedia, setStartAtParam, startAtParam] [playMedia, startAtParam]
); );
return ( return (

View file

@ -54,6 +54,7 @@ export default defineConfig(({ mode }) => {
theme_color: "#120f1d", theme_color: "#120f1d",
background_color: "#120f1d", background_color: "#120f1d",
display: "standalone", display: "standalone",
orientation: "portrait-primary",
start_url: "/", start_url: "/",
icons: [ icons: [
{ {