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);
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]
);

View File

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

View File

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

View File

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

View File

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