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 ServerConnections from 'components/ServerConnections';
|
||||
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 { ActionData } from 'types/actionData';
|
||||
|
||||
|
@ -42,16 +42,16 @@ const Logs = () => {
|
|||
const [ isSubmitting, setIsSubmitting ] = useState(false);
|
||||
|
||||
const { isPending: isLogEntriesPending, data: logs } = useServerLogs();
|
||||
const { isPending: isLogOptionsPending, data: defaultLogOptions } = useLogOptions();
|
||||
const { isPending: isConfigurationPending, data: defaultConfiguration } = useConfiguration();
|
||||
const [ loading, setLoading ] = useState(true);
|
||||
const [ logOptions, setLogOptions ] = useState<ServerConfiguration>( {} );
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLogOptionsPending && defaultLogOptions) {
|
||||
setLogOptions(defaultLogOptions);
|
||||
if (!isConfigurationPending && defaultConfiguration) {
|
||||
setLogOptions(defaultConfiguration);
|
||||
setLoading(false);
|
||||
}
|
||||
}, [isLogOptionsPending, defaultLogOptions]);
|
||||
}, [isConfigurationPending, defaultConfiguration]);
|
||||
|
||||
const setLogWarningMessage = useCallback((_: ChangeEvent<HTMLInputElement>, checked: boolean) => {
|
||||
setLogOptions({
|
||||
|
@ -71,7 +71,7 @@ const Logs = () => {
|
|||
setIsSubmitting(true);
|
||||
}, []);
|
||||
|
||||
if (isLogEntriesPending || isLogOptionsPending || loading) {
|
||||
if (isLogEntriesPending || isConfigurationPending || loading) {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||
import { useApi } from 'hooks/useApi';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
|
||||
export const fetchLogOptions = async (api?: Api, options?: AxiosRequestConfig) => {
|
||||
export const fetchConfiguration = async (api?: Api, options?: AxiosRequestConfig) => {
|
||||
if (!api) {
|
||||
console.error('[useLogOptions] No API instance available');
|
||||
return;
|
||||
|
@ -15,12 +15,12 @@ export const fetchLogOptions = async (api?: Api, options?: AxiosRequestConfig) =
|
|||
return response.data;
|
||||
};
|
||||
|
||||
export const useLogOptions = () => {
|
||||
export const useConfiguration = () => {
|
||||
const { api } = useApi();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['LogOptions'],
|
||||
queryFn: ({ signal }) => fetchLogOptions(api, { signal }),
|
||||
queryKey: ['Configuration'],
|
||||
queryFn: ({ signal }) => fetchConfiguration(api, { signal }),
|
||||
enabled: !!api
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue