Fix /s/ back to home

Co-authored-by: mrjvs <mistrjvs@gmail.com>
This commit is contained in:
Jip Fr 2023-12-16 14:46:46 +01:00
parent b91f0e4b3d
commit 15332c8fce

View file

@ -43,11 +43,17 @@ export function useHistoryListener() {
export function useLastNonPlayerLink() {
const routes = useHistoryStore((s) => s.routes);
const location = useLocation();
const lastNonPlayerLink = useMemo(() => {
const reversedRoutes = [...routes];
reversedRoutes.reverse();
const route = reversedRoutes.find((v) => !v.path.startsWith("/media"));
const route = reversedRoutes.find(
(v) =>
!v.path.startsWith("/media") && // cannot be a player link
location.pathname !== v.path && // cannot be current link
!v.path.startsWith("/s/") // cannot be a quick search link
);
return route?.path ?? "/";
}, [routes]);
}, [routes, location]);
return lastNonPlayerLink;
}