mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-03-02 07:52:34 +00:00
refactor: improve TypeScript type safety for router navigation
Replaces generic `any` type casts with specific route pattern types to enhance type checking and prevent invalid navigation paths. Adds backward compatibility alias for the navigation utility function to maintain existing API contracts while improving code organization.
This commit is contained in:
@@ -307,7 +307,7 @@ export const AppleTVCarousel: React.FC<AppleTVCarouselProps> = ({
|
||||
const navigateToItem = useCallback(
|
||||
(item: BaseItemDto) => {
|
||||
const navigation = getItemNavigation(item, "(home)");
|
||||
router.push(navigation as any);
|
||||
router.push(navigation as `/(auth)/(tabs)/${string}`);
|
||||
},
|
||||
[router],
|
||||
);
|
||||
|
||||
@@ -44,6 +44,9 @@ export const itemRouter = (item: BaseItemDto, from: string) => {
|
||||
return `/(auth)/(tabs)/${from}/items/page?id=${item.Id}`;
|
||||
};
|
||||
|
||||
// Export alias for backward compatibility
|
||||
export const getItemNavigation = itemRouter;
|
||||
|
||||
export const TouchableItemRouter: React.FC<PropsWithChildren<Props>> = ({
|
||||
item,
|
||||
isOffline = false,
|
||||
@@ -106,7 +109,7 @@ export const TouchableItemRouter: React.FC<PropsWithChildren<Props>> = ({
|
||||
if (isOffline) {
|
||||
url += `&offline=true`;
|
||||
}
|
||||
router.push(url);
|
||||
router.push(url as `/(auth)/(tabs)/${string}`);
|
||||
}}
|
||||
{...props}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user