mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-29 17:20:30 +01:00
When a user has advanced-request permission, the season-select sheet opened the advanced request modal via router.back() + push(). back() is batched, so the push landed first and the advanced sheet stacked on top of the season sheet, breaking focus. Add a `replace` option to showRequestModal and use it here so the advanced modal takes the season sheet's place in the stack. Claude-Session: https://claude.ai/code/session_016Hhu5DruGLPhdP4LAoy1Xd
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { useCallback } from "react";
|
|
import useRouter from "@/hooks/useAppRouter";
|
|
import { tvRequestModalAtom } from "@/utils/atoms/tvRequestModal";
|
|
import type { MediaType } from "@/utils/jellyseerr/server/constants/media";
|
|
import type { MediaRequestBody } from "@/utils/jellyseerr/server/interfaces/api/requestInterfaces";
|
|
import { store } from "@/utils/store";
|
|
|
|
interface ShowRequestModalParams {
|
|
requestBody: MediaRequestBody;
|
|
title: string;
|
|
id: number;
|
|
mediaType: MediaType;
|
|
onRequested: () => void;
|
|
/**
|
|
* Replace the current route instead of pushing. Use when opening the request
|
|
* modal from another modal (e.g. the season selector) so the new sheet takes
|
|
* its place rather than stacking on top of it (which breaks TV focus).
|
|
*/
|
|
replace?: boolean;
|
|
}
|
|
|
|
export const useTVRequestModal = () => {
|
|
const router = useRouter();
|
|
|
|
const showRequestModal = useCallback(
|
|
(params: ShowRequestModalParams) => {
|
|
store.set(tvRequestModalAtom, {
|
|
requestBody: params.requestBody,
|
|
title: params.title,
|
|
id: params.id,
|
|
mediaType: params.mediaType,
|
|
onRequested: params.onRequested,
|
|
});
|
|
if (params.replace) {
|
|
router.replace("/(auth)/tv-request-modal");
|
|
} else {
|
|
router.push("/(auth)/tv-request-modal");
|
|
}
|
|
},
|
|
[router],
|
|
);
|
|
|
|
return { showRequestModal };
|
|
};
|