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

Merge remote-tracking branch 'origin/master' into standalone

Conflicts:
	package.json
	src/components/appRouter.js
	src/components/require/requiretext.js
	src/config.json
	src/scripts/clientUtils.js
	src/scripts/settings/webSettings.js
	src/scripts/site.js
This commit is contained in:
Dmitry Lyzo 2020-11-21 21:03:18 +03:00
commit 5592cb7d4e
310 changed files with 7707 additions and 6701 deletions

View file

@ -0,0 +1,80 @@
import { ConnectionManager, Credentials, ApiClient, Events } from 'jellyfin-apiclient';
import { appHost } from './apphost';
import Dashboard from '../scripts/clientUtils';
import AppInfo from './AppInfo';
import { setUserInfo } from '../scripts/settings/userSettings';
class ServerConnections extends ConnectionManager {
constructor() {
super(...arguments);
this.localApiClient = null;
Events.on(this, 'localusersignedout', function () {
setUserInfo(null, null);
});
}
initApiClient(server) {
console.debug('creating ApiClient singleton');
const apiClient = new ApiClient(
server,
appHost.appName(),
appHost.appVersion(),
appHost.deviceName(),
appHost.deviceId()
);
apiClient.enableAutomaticNetworking = false;
apiClient.manualAddressOnly = true;
this.addApiClient(apiClient);
this.setLocalApiClient(apiClient);
console.debug('loaded ApiClient singleton');
}
setLocalApiClient(apiClient) {
if (apiClient) {
this.localApiClient = apiClient;
window.ApiClient = apiClient;
}
}
getLocalApiClient() {
return this.localApiClient;
}
currentApiClient() {
let apiClient = this.getLocalApiClient();
if (!apiClient) {
const server = this.getLastUsedServer();
if (server) {
apiClient = this.getApiClient(server.Id);
}
}
return apiClient;
}
onLocalUserSignedIn(user) {
const apiClient = this.getApiClient(user.ServerId);
this.setLocalApiClient(apiClient);
return setUserInfo(user.Id, apiClient);
}
}
const credentials = new Credentials();
const capabilities = Dashboard.capabilities(appHost);
export default new ServerConnections(
credentials,
appHost.appName(),
appHost.appVersion(),
appHost.deviceName(),
appHost.deviceId(),
capabilities);