Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/apps/dashboard/features/livetv/api/useTunerHostTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useQuery } from '@tanstack/react-query';

import { useApi } from 'hooks/useApi';
import { getLiveTvApi } from '@jellyfin/sdk/lib/utils/api/live-tv-api';

export const useTunerHostTypes = () => {
const { api } = useApi();

return useQuery({
queryKey: [ 'TunerHostTypes' ],
queryFn: async () => (await getLiveTvApi(api!).getTunerHostTypes()).data,
enabled: !!api
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import globalize from 'lib/globalize';
import { useNavigate } from 'react-router-dom';
import ConfirmDialog from 'components/ConfirmDialog';
import { useDeleteTuner } from '../api/useDeleteTuner';
import { useTunerHostTypes } from '../api/useTunerHostTypes';

interface TunerDeviceCardProps {
tunerHost: TunerHostInfo;
Expand All @@ -25,6 +26,11 @@ const TunerDeviceCard = ({ tunerHost }: TunerDeviceCardProps) => {
const [ isMenuOpen, setIsMenuOpen ] = useState(false);
const [ isConfirmDeleteDialogOpen, setIsConfirmDeleteDialogOpen ] = useState(false);
const deleteTuner = useDeleteTuner();
const { data: tunerTypes } = useTunerHostTypes();

// Prefer the name the server reports for this tuner type; this covers plugin-provided tuners that the
// static getTunerName() list does not know about. getTunerName is kept as a fallback while it loads.
const typeName = tunerTypes?.find(type => type.Id === tunerHost.Type)?.Name;

const navigateToEditPage = useCallback(() => {
navigate(`/dashboard/livetv/tuner?id=${tunerHost.Id}`);
Expand Down Expand Up @@ -75,7 +81,7 @@ const TunerDeviceCard = ({ tunerHost }: TunerDeviceCardProps) => {
/>

<BaseCard
title={tunerHost.FriendlyName || getTunerName(tunerHost.Type) || ''}
title={tunerHost.FriendlyName || typeName || getTunerName(tunerHost.Type) || ''}
text={tunerHost.Url || ''}
icon={<DvrIcon sx={{ fontSize: 70 }} />}
action={true}
Expand Down