mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add device deletion support
This commit is contained in:
parent
538c0b64ff
commit
e10aef9933
8 changed files with 286 additions and 120 deletions
|
@ -1,11 +1,13 @@
|
|||
import type { AxiosRequestConfig } from 'axios';
|
||||
import type { Api } from '@jellyfin/sdk';
|
||||
import type { UserApiGetUsersRequest } from '@jellyfin/sdk/lib/generated-client';
|
||||
import type { UserApiGetUsersRequest, UserDto } from '@jellyfin/sdk/lib/generated-client';
|
||||
import { getUserApi } from '@jellyfin/sdk/lib/utils/api/user-api';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { useApi } from './useApi';
|
||||
|
||||
export type UsersRecords = Record<string, UserDto>;
|
||||
|
||||
const fetchUsers = async (
|
||||
api?: Api,
|
||||
requestParams?: UserApiGetUsersRequest,
|
||||
|
@ -32,3 +34,24 @@ export const useUsers = (requestParams?: UserApiGetUsersRequest) => {
|
|||
enabled: !!api
|
||||
});
|
||||
};
|
||||
|
||||
export const useUsersDetails = () => {
|
||||
const { data: users, ...rest } = useUsers();
|
||||
const usersById: UsersRecords = {};
|
||||
const names: string[] = [];
|
||||
|
||||
if (users) {
|
||||
users.forEach(user => {
|
||||
const userId = user.Id;
|
||||
if (userId) usersById[userId] = user;
|
||||
if (user.Name) names.push(user.Name);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
users,
|
||||
usersById,
|
||||
names,
|
||||
...rest
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue