mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-26 07:31:50 +01:00
Fix /s/ back to home
Co-authored-by: mrjvs <mistrjvs@gmail.com>
This commit is contained in:
parent
b91f0e4b3d
commit
15332c8fce
@ -43,11 +43,17 @@ export function useHistoryListener() {
|
|||||||
|
|
||||||
export function useLastNonPlayerLink() {
|
export function useLastNonPlayerLink() {
|
||||||
const routes = useHistoryStore((s) => s.routes);
|
const routes = useHistoryStore((s) => s.routes);
|
||||||
|
const location = useLocation();
|
||||||
const lastNonPlayerLink = useMemo(() => {
|
const lastNonPlayerLink = useMemo(() => {
|
||||||
const reversedRoutes = [...routes];
|
const reversedRoutes = [...routes];
|
||||||
reversedRoutes.reverse();
|
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 ?? "/";
|
return route?.path ?? "/";
|
||||||
}, [routes]);
|
}, [routes, location]);
|
||||||
return lastNonPlayerLink;
|
return lastNonPlayerLink;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user