mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add build and web versions to dashboard
This commit is contained in:
parent
4a6efbe359
commit
1aabbae3a5
11 changed files with 95 additions and 39 deletions
|
@ -3,21 +3,34 @@ import type { Api } from '@jellyfin/sdk';
|
|||
import { getSystemApi } from '@jellyfin/sdk/lib/utils/api/system-api';
|
||||
import type { AxiosRequestConfig } from 'axios';
|
||||
|
||||
import { useApi } from './useApi';
|
||||
import { queryOptions } from 'utils/query/queryOptions';
|
||||
|
||||
const fetchSystemInfo = async (
|
||||
api: Api | undefined,
|
||||
options: AxiosRequestConfig
|
||||
api?: Api,
|
||||
options?: AxiosRequestConfig
|
||||
) => {
|
||||
if (!api) throw new Error('No API instance available');
|
||||
if (!api) {
|
||||
console.warn('[fetchSystemInfo] No API instance available');
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await getSystemApi(api)
|
||||
.getSystemInfo(options);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useSystemInfo = (api: Api | undefined) => {
|
||||
return useQuery({
|
||||
queryKey: [ 'SystemInfo' ],
|
||||
queryFn: ({ signal }) => fetchSystemInfo(api, { signal }),
|
||||
enabled: !!api
|
||||
});
|
||||
export const getSystemInfoQuery = (
|
||||
api?: Api
|
||||
) => queryOptions({
|
||||
queryKey: [ 'SystemInfo' ],
|
||||
queryFn: ({ signal }) => fetchSystemInfo(api, { signal }),
|
||||
// Allow for query reuse in legacy javascript.
|
||||
staleTime: 1000, // 1 second
|
||||
enabled: !!api
|
||||
});
|
||||
|
||||
export const useSystemInfo = () => {
|
||||
const { api } = useApi();
|
||||
return useQuery(getSystemInfoQuery(api));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue