mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
21 lines
664 B
TypeScript
21 lines
664 B
TypeScript
![]() |
import { getDefaultTabIndex } from 'apps/experimental/components/tabs/tabRoutes';
|
||
|
import { useLocation, useSearchParams } from 'react-router-dom';
|
||
|
|
||
|
const useCurrentTab = () => {
|
||
|
const location = useLocation();
|
||
|
const [searchParams] = useSearchParams();
|
||
|
const searchParamsParentId = searchParams.get('topParentId');
|
||
|
const searchParamsTab = searchParams.get('tab');
|
||
|
const currentTabIndex: number =
|
||
|
searchParamsTab !== null ?
|
||
|
parseInt(searchParamsTab, 10) :
|
||
|
getDefaultTabIndex(location.pathname, searchParamsParentId);
|
||
|
|
||
|
return {
|
||
|
searchParamsParentId,
|
||
|
currentTabIndex
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export default useCurrentTab;
|