1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add api and user contexts

This commit is contained in:
Bill Thornton 2022-10-28 01:09:59 -04:00
parent f20ceb4274
commit d297f23932
8 changed files with 124 additions and 22 deletions

23
src/utils/sdk.ts Normal file
View file

@ -0,0 +1,23 @@
import { Api, Jellyfin } from '@jellyfin/sdk';
import { ApiClient } from 'jellyfin-apiclient';
/**
* Returns an SDK Api instance using the same parameters as the provided ApiClient.
* @param {ApiClient} apiClient The (legacy) ApiClient.
* @returns {Api} An equivalent SDK Api instance.
*/
export const toApi = (apiClient: ApiClient): Api => {
return (new Jellyfin({
clientInfo: {
name: apiClient.appName(),
version: apiClient.appVersion()
},
deviceInfo: {
name: apiClient.deviceName(),
id: apiClient.deviceId()
}
})).createApi(
apiClient.serverAddress(),
apiClient.accessToken()
);
};