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

extracted connectionManager from site.js

new module ServerConnections for ConnectionManager
all code adapted to this new module
removed Events and ConnectionManager from eslintrc
This commit is contained in:
vitorsemeano 2020-10-17 19:08:56 +01:00
parent 923d53bb71
commit 5071aedcea
81 changed files with 446 additions and 397 deletions

View file

@ -1,5 +1,5 @@
/* eslint-disable indent */
import { ConnectionManager } from 'jellyfin-apiclient';
import ServerConnections from '../../components/ServerConnections';
class BackdropScreensaver {
constructor() {
@ -21,7 +21,7 @@ class BackdropScreensaver {
Limit: 200
};
const apiClient = window.ConnectionManager.currentApiClient();
const apiClient = ServerConnections.currentApiClient();
apiClient.getItems(apiClient.getCurrentUserId(), query).then((result) => {
if (result.Items.length) {
import('../../components/slideshow/slideshow').then(({default: Slideshow}) => {

View file

@ -2,11 +2,11 @@ import loading from '../../components/loading/loading';
import keyboardnavigation from '../../scripts/keyboardNavigation';
import dialogHelper from '../../components/dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import { ConnectionManager, Events } from 'jellyfin-apiclient';
import { Events } from 'jellyfin-apiclient';
import './style.css';
import 'material-design-icons-iconfont';
import '../../elements/emby-button/paper-icon-button-light';
import ServerConnections from '../../components/ServerConnections';
import TableOfContents from './tableOfContents';
export class BookPlayer {
@ -259,7 +259,7 @@ export class BookPlayer {
};
const serverId = item.ServerId;
const apiClient = ConnectionManager.getApiClient(serverId);
const apiClient = ServerConnections.getApiClient(serverId);
return new Promise((resolve, reject) => {
import('epubjs').then(({default: epubjs}) => {

View file

@ -1,4 +1,5 @@
import { Events, ConnectionManager } from 'jellyfin-apiclient';
import { Events } from 'jellyfin-apiclient';
import ServerConnections from '../../components/ServerConnections';
// LinkParser
//
@ -221,8 +222,8 @@ function getCachedValue(key) {
return null;
}
Events.on(ConnectionManager, 'localusersignedin', clearCache);
Events.on(ConnectionManager, 'localusersignedout', clearCache);
Events.on(ServerConnections, 'localusersignedin', clearCache);
Events.on(ServerConnections, 'localusersignedout', clearCache);
export default {
getServerAddress: getServerAddress

View file

@ -2,8 +2,9 @@ import appSettings from '../../scripts/settings/appSettings';
import * as userSettings from '../../scripts/settings/userSettings';
import { playbackManager } from '../../components/playback/playbackmanager';
import globalize from '../../scripts/globalize';
import { ConnectionManager, Events } from 'jellyfin-apiclient';
import { Events } from 'jellyfin-apiclient';
import castSenderApiLoader from '../../components/castSenderApi';
import ServerConnections from '../../components/ServerConnections';
// Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js
@ -324,11 +325,11 @@ class CastPlayer {
let apiClient;
if (message.options && message.options.ServerId) {
apiClient = ConnectionManager.getApiClient(message.options.ServerId);
apiClient = ServerConnections.getApiClient(message.options.ServerId);
} else if (message.options && message.options.items && message.options.items.length) {
apiClient = ConnectionManager.getApiClient(message.options.items[0].ServerId);
apiClient = ServerConnections.getApiClient(message.options.items[0].ServerId);
} else {
apiClient = window.ConnectionManager.currentApiClient();
apiClient = ServerConnections.currentApiClient();
}
message = Object.assign(message, {
@ -672,7 +673,7 @@ class ChromecastPlayer {
playWithCommand(options, command) {
if (!options.items) {
const apiClient = ConnectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
const instance = this;
return apiClient.getItem(apiClient.getCurrentUserId(), options.ids[0]).then(function (item) {
@ -984,7 +985,7 @@ class ChromecastPlayer {
}
shuffle(item) {
const apiClient = ConnectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const userId = apiClient.getCurrentUserId();
const instance = this;
@ -997,7 +998,7 @@ class ChromecastPlayer {
}
instantMix(item) {
const apiClient = ConnectionManager.getApiClient(item.ServerId);
const apiClient = ServerConnections.getApiClient(item.ServerId);
const userId = apiClient.getCurrentUserId();
const instance = this;
@ -1035,7 +1036,7 @@ class ChromecastPlayer {
}
const instance = this;
const apiClient = ConnectionManager.getApiClient(options.serverId);
const apiClient = ServerConnections.getApiClient(options.serverId);
return getItemsForPlayback(apiClient, {
Ids: options.ids.join(',')

View file

@ -1,5 +1,5 @@
import browser from '../../scripts/browser';
import { ConnectionManager, Events } from 'jellyfin-apiclient';
import { Events } from 'jellyfin-apiclient';
import { appHost } from '../../components/apphost';
import loading from '../../components/loading/loading';
import dom from '../../scripts/dom';
@ -26,6 +26,7 @@ import {
import itemHelper from '../../components/itemHelper';
import Screenfull from 'screenfull';
import globalize from '../../scripts/globalize';
import ServerConnections from '../../components/ServerConnections';
/* eslint-disable indent */
@ -323,7 +324,7 @@ function tryRemoveElement(elem) {
console.debug(`prefetching hls playlist: ${hlsPlaylistUrl}`);
return ConnectionManager.getApiClient(item.ServerId).ajax({
return ServerConnections.getApiClient(item.ServerId).ajax({
type: 'GET',
url: hlsPlaylistUrl
@ -1031,7 +1032,7 @@ function tryRemoveElement(elem) {
*/
renderSsaAss(videoElement, track, item) {
const attachments = this._currentPlayOptions.mediaSource.MediaAttachments || [];
const apiClient = ConnectionManager.getApiClient(item);
const apiClient = ServerConnections.getApiClient(item);
const htmlVideoPlayer = this;
const options = {
video: videoElement,

View file

@ -1,4 +1,4 @@
import { ConnectionManager } from 'jellyfin-apiclient';
import ServerConnections from '../../components/ServerConnections';
export default class PhotoPlayer {
constructor() {
@ -13,7 +13,7 @@ export default class PhotoPlayer {
import('../../components/slideshow/slideshow').then(({default: Slideshow}) => {
var index = options.startIndex || 0;
var apiClient = window.ConnectionManager.currentApiClient();
var apiClient = ServerConnections.currentApiClient();
apiClient.getCurrentUser().then(function(result) {
var newSlideShow = new Slideshow({
showTitle: false,

View file

@ -1,5 +1,5 @@
import { ConnectionManager } from 'jellyfin-apiclient';
import globalize from '../../scripts/globalize';
import ServerConnections from '../../components/ServerConnections';
function showErrorMessage() {
return import('../../components/alert').then(({default: alert}) => {
@ -25,7 +25,7 @@ class PlayAccessValidation {
return Promise.resolve();
}
return ConnectionManager.getApiClient(serverId).getCurrentUser().then(function (user) {
return ServerConnections.getApiClient(serverId).getCurrentUser().then(function (user) {
if (user.Policy.EnableMediaPlayback) {
return Promise.resolve();
}

View file

@ -1,6 +1,7 @@
import { playbackManager } from '../../components/playback/playbackmanager';
import { ConnectionManager, Events } from 'jellyfin-apiclient';
import { Events } from 'jellyfin-apiclient';
import serverNotifications from '../../scripts/serverNotifications';
import ServerConnections from '../../components/ServerConnections';
function getActivePlayerId() {
const info = playbackManager.getPlayerInfo();
@ -53,10 +54,10 @@ function getCurrentApiClient(instance) {
const currentServerId = instance.currentServerId;
if (currentServerId) {
return ConnectionManager.getApiClient(currentServerId);
return ServerConnections.getApiClient(currentServerId);
}
return window.ConnectionManager.currentApiClient();
return ServerConnections.currentApiClient();
}
function sendCommandByName(instance, name, options) {