mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate libraries metadata to React
This commit is contained in:
parent
1693618589
commit
c8d2ce4142
9 changed files with 222 additions and 145 deletions
21
src/apps/dashboard/features/libraries/api/useCountries.ts
Normal file
21
src/apps/dashboard/features/libraries/api/useCountries.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { Api } from '@jellyfin/sdk';
|
||||
import { getLocalizationApi } from '@jellyfin/sdk/lib/utils/api/localization-api';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useApi } from 'hooks/useApi';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
|
||||
const fetchCountries = async (api: Api, options?: AxiosRequestConfig) => {
|
||||
const response = await getLocalizationApi(api).getCountries(options);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useCountries = () => {
|
||||
const { api } = useApi();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [ 'Countries' ],
|
||||
queryFn: ({ signal }) => fetchCountries(api!, { signal }),
|
||||
enabled: !!api
|
||||
});
|
||||
};
|
21
src/apps/dashboard/features/libraries/api/useCultures.ts
Normal file
21
src/apps/dashboard/features/libraries/api/useCultures.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { Api } from '@jellyfin/sdk';
|
||||
import { getLocalizationApi } from '@jellyfin/sdk/lib/utils/api/localization-api';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useApi } from 'hooks/useApi';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
|
||||
const fetchCultures = async (api: Api, options?: AxiosRequestConfig) => {
|
||||
const response = await getLocalizationApi(api).getCultures(options);
|
||||
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useCultures = () => {
|
||||
const { api } = useApi();
|
||||
|
||||
return useQuery({
|
||||
queryKey: [ 'Cultures' ],
|
||||
queryFn: ({ signal }) => fetchCultures(api!, { signal }),
|
||||
enabled: !!api
|
||||
});
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
import { ImageResolution } from '@jellyfin/sdk/lib/generated-client/models/image-resolution';
|
||||
import globalize from 'lib/globalize';
|
||||
|
||||
export function getImageResolutionOptions() {
|
||||
return [
|
||||
{
|
||||
name: globalize.translate('ResolutionMatchSource'),
|
||||
value: ImageResolution.MatchSource
|
||||
},
|
||||
{ name: '2160p', value: ImageResolution.P2160 },
|
||||
{ name: '1440p', value: ImageResolution.P1440 },
|
||||
{ name: '1080p', value: ImageResolution.P1080 },
|
||||
{ name: '720p', value: ImageResolution.P720 },
|
||||
{ name: '480p', value: ImageResolution.P480 },
|
||||
{ name: '360p', value: ImageResolution.P360 },
|
||||
{ name: '240p', value: ImageResolution.P240 },
|
||||
{ name: '144p', value: ImageResolution.P144 }
|
||||
];
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue