mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Rename to useConfiguration
This commit is contained in:
parent
da31c9856c
commit
ec6e0d368b
2 changed files with 10 additions and 10 deletions
|
@ -8,7 +8,7 @@ import { Alert, Box, Button, FormControlLabel, Stack, Switch, TextField, Typogra
|
||||||
import { type ActionFunctionArgs, Form, useActionData } from 'react-router-dom';
|
import { type ActionFunctionArgs, Form, useActionData } from 'react-router-dom';
|
||||||
import ServerConnections from 'components/ServerConnections';
|
import ServerConnections from 'components/ServerConnections';
|
||||||
import { useServerLogs } from 'apps/dashboard/features/logs/api/useServerLogs';
|
import { useServerLogs } from 'apps/dashboard/features/logs/api/useServerLogs';
|
||||||
import { useLogOptions } from 'apps/dashboard/features/logs/api/useLogOptions';
|
import { useConfiguration } from 'hooks/useConfiguration';
|
||||||
import type { ServerConfiguration } from '@jellyfin/sdk/lib/generated-client/models/server-configuration';
|
import type { ServerConfiguration } from '@jellyfin/sdk/lib/generated-client/models/server-configuration';
|
||||||
import { ActionData } from 'types/actionData';
|
import { ActionData } from 'types/actionData';
|
||||||
|
|
||||||
|
@ -42,16 +42,16 @@ const Logs = () => {
|
||||||
const [ isSubmitting, setIsSubmitting ] = useState(false);
|
const [ isSubmitting, setIsSubmitting ] = useState(false);
|
||||||
|
|
||||||
const { isPending: isLogEntriesPending, data: logs } = useServerLogs();
|
const { isPending: isLogEntriesPending, data: logs } = useServerLogs();
|
||||||
const { isPending: isLogOptionsPending, data: defaultLogOptions } = useLogOptions();
|
const { isPending: isConfigurationPending, data: defaultConfiguration } = useConfiguration();
|
||||||
const [ loading, setLoading ] = useState(true);
|
const [ loading, setLoading ] = useState(true);
|
||||||
const [ logOptions, setLogOptions ] = useState<ServerConfiguration>( {} );
|
const [ logOptions, setLogOptions ] = useState<ServerConfiguration>( {} );
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLogOptionsPending && defaultLogOptions) {
|
if (!isConfigurationPending && defaultConfiguration) {
|
||||||
setLogOptions(defaultLogOptions);
|
setLogOptions(defaultConfiguration);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [isLogOptionsPending, defaultLogOptions]);
|
}, [isConfigurationPending, defaultConfiguration]);
|
||||||
|
|
||||||
const setLogWarningMessage = useCallback((_: ChangeEvent<HTMLInputElement>, checked: boolean) => {
|
const setLogWarningMessage = useCallback((_: ChangeEvent<HTMLInputElement>, checked: boolean) => {
|
||||||
setLogOptions({
|
setLogOptions({
|
||||||
|
@ -71,7 +71,7 @@ const Logs = () => {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (isLogEntriesPending || isLogOptionsPending || loading) {
|
if (isLogEntriesPending || isConfigurationPending || loading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||||
import { useApi } from 'hooks/useApi';
|
import { useApi } from 'hooks/useApi';
|
||||||
import type { AxiosRequestConfig } from 'axios';
|
import type { AxiosRequestConfig } from 'axios';
|
||||||
|
|
||||||
export const fetchLogOptions = async (api?: Api, options?: AxiosRequestConfig) => {
|
export const fetchConfiguration = async (api?: Api, options?: AxiosRequestConfig) => {
|
||||||
if (!api) {
|
if (!api) {
|
||||||
console.error('[useLogOptions] No API instance available');
|
console.error('[useLogOptions] No API instance available');
|
||||||
return;
|
return;
|
||||||
|
@ -15,12 +15,12 @@ export const fetchLogOptions = async (api?: Api, options?: AxiosRequestConfig) =
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useLogOptions = () => {
|
export const useConfiguration = () => {
|
||||||
const { api } = useApi();
|
const { api } = useApi();
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['LogOptions'],
|
queryKey: ['Configuration'],
|
||||||
queryFn: ({ signal }) => fetchLogOptions(api, { signal }),
|
queryFn: ({ signal }) => fetchConfiguration(api, { signal }),
|
||||||
enabled: !!api
|
enabled: !!api
|
||||||
});
|
});
|
||||||
};
|
};
|
Loading…
Add table
Add a link
Reference in a new issue