Use connectionManager global

This commit is contained in:
MrTimscampi 2020-08-30 06:06:47 +02:00
parent 4d540bf9ca
commit c97d7a6f59
79 changed files with 233 additions and 319 deletions

View File

@ -4,7 +4,6 @@ import dom from 'dom';
import * as datefns from 'date-fns';
import dfnshelper from 'dfnshelper';
import serverNotifications from 'serverNotifications';
import connectionManager from 'connectionManager';
import 'emby-button';
import 'listViewStyle';
@ -141,7 +140,7 @@ class ActivityLog {
const element = options.element;
element.classList.add('activityLogListWidget');
element.addEventListener('click', onListClick.bind(this));
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
reloadData(this, element, apiClient);
const onUpdate = onActivityLogUpdate.bind(this);
this.updateFn = onUpdate;
@ -153,7 +152,7 @@ class ActivityLog {
if (options) {
options.element.classList.remove('activityLogListWidget');
connectionManager.getApiClient(options.serverId).sendMessage('ActivityLogEntryStop', '0,1500');
window.connectionManager.getApiClient(options.serverId).sendMessage('ActivityLogEntryStop', '0,1500');
}
const onUpdate = this.updateFn;

View File

@ -2,7 +2,6 @@ import appHost from 'apphost';
import appSettings from 'appSettings';
import backdrop from 'backdrop';
import browser from 'browser';
import connectionManager from 'connectionManager';
import events from 'events';
import globalize from 'globalize';
import itemHelper from 'itemHelper';
@ -95,7 +94,7 @@ class AppRouter {
beginConnectionWizard() {
backdrop.clearBackdrop();
loading.show();
connectionManager.connect({
window.connectionManager.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
this.handleConnectionResult(result);
@ -154,7 +153,7 @@ class AppRouter {
events.on(appHost, 'beforeexit', this.onBeforeExit);
events.on(appHost, 'resume', this.onAppResume);
connectionManager.connect({
window.connectionManager.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then((result) => {
this.firstConnectionResult = result;
@ -210,7 +209,7 @@ class AppRouter {
showItem(item, serverId, options) {
// TODO: Refactor this so it only gets items, not strings.
if (typeof (item) === 'string') {
const apiClient = serverId ? connectionManager.getApiClient(serverId) : connectionManager.currentApiClient();
const apiClient = serverId ? window.connectionManager.getApiClient(serverId) : window.connectionManager.currentApiClient();
apiClient.getItem(apiClient.getCurrentUserId(), item).then((itemObject) => {
this.showItem(itemObject, options);
});
@ -492,15 +491,15 @@ class AppRouter {
}
initApiClients() {
connectionManager.getApiClients().forEach((apiClient) => {
window.connectionManager.getApiClients().forEach((apiClient) => {
this.initApiClient(apiClient, this);
});
events.on(connectionManager, 'apiclientcreated', this.onApiClientCreated);
events.on(window.connectionManager, 'apiclientcreated', this.onApiClientCreated);
}
onAppResume() {
const apiClient = connectionManager.currentApiClient();
const apiClient = window.connectionManager.currentApiClient();
if (apiClient) {
apiClient.ensureWebSocket();
@ -518,7 +517,7 @@ class AppRouter {
}
}
const apiClient = connectionManager.currentApiClient();
const apiClient = window.connectionManager.currentApiClient();
const pathname = ctx.pathname.toLowerCase();
console.debug('appRouter - processing path request ' + pathname);

View File

@ -1,5 +1,4 @@
import browser from 'browser';
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import dom from 'dom';
import * as userSettings from 'userSettings';
@ -177,7 +176,7 @@ import 'css!./backdrop';
function getItemImageUrls(item, imageOptions) {
imageOptions = imageOptions || {};
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
if (item.BackdropImageTags && item.BackdropImageTags.length > 0) {
return item.BackdropImageTags.map((imgTag, index) => {
return apiClient.getScaledImageUrl(item.BackdropItemId || item.Id, Object.assign(imageOptions, {

View File

@ -7,7 +7,6 @@
import datetime from 'datetime';
import imageLoader from 'imageLoader';
import connectionManager from 'connectionManager';
import itemHelper from 'itemHelper';
import focusManager from 'focusManager';
import indicators from 'indicators';
@ -371,7 +370,7 @@ import 'programStyles';
if (serverId !== lastServerId) {
lastServerId = serverId;
apiClient = connectionManager.getApiClient(lastServerId);
apiClient = window.connectionManager.getApiClient(lastServerId);
}
if (options.indexBy) {

View File

@ -7,7 +7,6 @@
import datetime from 'datetime';
import imageLoader from 'imageLoader';
import connectionManager from 'connectionManager';
import layoutManager from 'layoutManager';
import browser from 'browser';
@ -48,7 +47,7 @@ import browser from 'browser';
let html = '';
let itemsInRow = 0;
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
for (let i = 0, length = chapters.length; i < length; i++) {
if (options.rows && itemsInRow === 0) {

View File

@ -1,7 +1,6 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import actionsheet from 'actionsheet';
import 'emby-input';
@ -16,7 +15,7 @@ export default class channelMapper {
function mapChannel(button, channelId, providerChannelId) {
loading.show();
const providerId = options.providerId;
connectionManager.getApiClient(options.serverId).ajax({
window.connectionManager.getApiClient(options.serverId).ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ChannelMappings'),
data: JSON.stringify({
@ -58,7 +57,7 @@ export default class channelMapper {
}
function getChannelMappingOptions(serverId, providerId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getJSON(apiClient.getUrl('LiveTv/ChannelMappingOptions', {
providerId: providerId
}));

View File

@ -2,7 +2,6 @@ import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import appRouter from 'appRouter';
import globalize from 'globalize';
import 'emby-checkbox';
@ -25,7 +24,7 @@ import 'flexStyles';
const collectionId = panel.querySelector('#selectCollectionToAddTo').value;
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
if (collectionId) {
addToCollection(apiClient, panel, collectionId);
@ -106,7 +105,7 @@ import 'flexStyles';
EnableTotalRecordCount: false
};
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
apiClient.getItems(apiClient.getCurrentUserId(), options).then(result => {
let html = '';

View File

@ -6,7 +6,6 @@ import focusManager from 'focusManager';
import datetime from 'datetime';
import globalize from 'globalize';
import loading from 'loading';
import connectionManager from 'connectionManager';
import skinManager from 'skinManager';
import events from 'events';
import 'emby-select';
@ -182,7 +181,7 @@ import 'emby-button';
function onSubmit(e) {
const self = this;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;
@ -221,7 +220,7 @@ import 'emby-button';
loading.show();
const userId = self.options.userId;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
return apiClient.getUser(userId).then(user => {

View File

@ -1,7 +1,6 @@
import dom from 'dom';
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import events from 'events';
import 'emby-checkbox';
import 'emby-collapse';
@ -420,7 +419,7 @@ import 'css!./style.css';
this.bindEvents(dlg);
if (enableDynamicFilters(this.options.mode)) {
dlg.classList.add('dynamicFilterDialog');
const apiClient = connectionManager.getApiClient(this.options.serverId);
const apiClient = window.connectionManager.getApiClient(this.options.serverId);
loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), this.options.query);
}
});

View File

@ -3,7 +3,6 @@ import focusManager from 'focusManager';
import dialogHelper from 'dialogHelper';
import inputManager from 'inputManager';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import * as userSettings from 'userSettings';
import 'emby-checkbox';
@ -194,7 +193,7 @@ function initEditor(context, settings) {
}
}
function loadDynamicFilters(context, options) {
var apiClient = connectionManager.getApiClient(options.serverId);
var apiClient = window.connectionManager.getApiClient(options.serverId);
var filterMenuOptions = Object.assign(options.filterMenuOptions, {

View File

@ -2,12 +2,11 @@
import dom from 'dom';
import appRouter from 'appRouter';
import connectionManager from 'connectionManager';
function onGroupedCardClick(e, card) {
var itemId = card.getAttribute('data-id');
var serverId = card.getAttribute('data-serverid');
var apiClient = connectionManager.getApiClient(serverId);
var apiClient = window.connectionManager.getApiClient(serverId);
var userId = apiClient.getCurrentUserId();
var playedIndicator = card.querySelector('.playedIndicator');
var playedIndicatorHtml = playedIndicator ? playedIndicator.innerHTML : null;

View File

@ -1,7 +1,6 @@
import inputManager from 'inputManager';
import browser from 'browser';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import scrollHelper from 'scrollHelper';
import serverNotifications from 'serverNotifications';
import loading from 'loading';
@ -213,7 +212,7 @@ function Guide(options) {
}
function reloadGuide(context, newStartDate, scrollToTimeMs, focusToTimeMs, startTimeOfDayMs, focusProgramOnRender) {
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
const channelQuery = {
@ -873,7 +872,7 @@ function Guide(options) {
function reloadPage(page) {
showLoading();
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
apiClient.getLiveTvGuideInfo().then(function (guideInfo) {
setDateRange(page, guideInfo);

View File

@ -2,7 +2,6 @@ import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import globalize from 'globalize';
import loading from 'loading';
import connectionManager from 'connectionManager';
import homeSections from 'homeSections';
import dom from 'dom';
import events from 'events';
@ -380,7 +379,7 @@ import 'emby-checkbox';
function onSubmit(e) {
const self = this;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;
@ -452,7 +451,7 @@ import 'emby-checkbox';
loading.show();
const userId = self.options.userId;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
apiClient.getUser(userId).then(user => {

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import cardBuilder from 'cardBuilder';
import dom from 'dom';
import layoutManager from 'layoutManager';
@ -212,7 +211,7 @@ import 'css!./homesections';
function getFetchLatestItemsFn(serverId, parentId, collectionType) {
return function () {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
let limit = 16;
if (enableScrollX()) {
@ -368,7 +367,7 @@ import 'css!./homesections';
function getContinueWatchingFetchFn(serverId) {
return function () {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const screenWidth = dom.getWindowSize().innerWidth;
let limit;
@ -441,7 +440,7 @@ import 'css!./homesections';
function getContinueListeningFetchFn(serverId) {
return function () {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const screenWidth = dom.getWindowSize().innerWidth;
let limit;
@ -514,7 +513,7 @@ import 'css!./homesections';
function getOnNowFetchFn(serverId) {
return function () {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getLiveTvRecommendedPrograms({
userId: apiClient.getCurrentUserId(),
IsAiring: true,
@ -657,7 +656,7 @@ import 'css!./homesections';
function getNextUpFetchFn(serverId) {
return function () {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getNextUpEpisodes({
Limit: enableScrollX() ? 24 : 15,
Fields: 'PrimaryImageAspectRatio,SeriesInfo,DateCreated,BasicSyncInfo,Path',
@ -728,7 +727,7 @@ import 'css!./homesections';
function getLatestRecordingsFetchFn(serverId, activeRecordingsOnly) {
return function () {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getLiveTvRecordings({
userId: apiClient.getCurrentUserId(),
Limit: enableScrollX() ? 12 : 5,

View File

@ -2,7 +2,6 @@ import dom from 'dom';
import loading from 'loading';
import appHost from 'apphost';
import dialogHelper from 'dialogHelper';
import connectionManager from 'connectionManager';
import imageLoader from 'imageLoader';
import browser from 'browser';
import layoutManager from 'layoutManager';
@ -317,7 +316,7 @@ import 'cardStyle';
loading.show();
import('text!./imageDownloader.template.html').then(({default: template}) => {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
currentItemId = itemId;
currentItemType = itemType;

View File

@ -6,7 +6,6 @@
*/
import dialogHelper from 'dialogHelper';
import connectionManager from 'connectionManager';
import dom from 'dom';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
@ -108,7 +107,7 @@ import 'css!./style';
return false;
}
connectionManager.getApiClient(currentServerId).uploadItemImage(currentItemId, imageType, file).then(() => {
window.connectionManager.getApiClient(currentServerId).uploadItemImage(currentItemId, imageType, file).then(() => {
dlg.querySelector('#uploadImage').value = '';
loading.hide();

View File

@ -1,5 +1,4 @@
import dialogHelper from 'dialogHelper';
import connectionManager from 'connectionManager';
import loading from 'loading';
import dom from 'dom';
import layoutManager from 'layoutManager';
@ -36,10 +35,10 @@ import 'css!./imageeditor';
let apiClient;
if (item) {
apiClient = connectionManager.getApiClient(item.ServerId);
apiClient = window.connectionManager.getApiClient(item.ServerId);
reloadItem(page, item, apiClient, focusContext);
} else {
apiClient = connectionManager.getApiClient(currentItem.ServerId);
apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
apiClient.getItem(apiClient.getCurrentUserId(), currentItem.Id).then(function (item) {
reloadItem(page, item, apiClient, focusContext);
});
@ -293,7 +292,7 @@ import 'css!./imageeditor';
function showActionSheet(context, imageCard) {
const itemId = imageCard.getAttribute('data-id');
const serverId = imageCard.getAttribute('data-serverid');
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const type = imageCard.getAttribute('data-imagetype');
const index = parseInt(imageCard.getAttribute('data-index'));
@ -404,7 +403,7 @@ import 'css!./imageeditor';
const type = this.getAttribute('data-imagetype');
let index = this.getAttribute('data-index');
index = index === 'null' ? null : parseInt(index);
const apiClient = connectionManager.getApiClient(currentItem.ServerId);
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
deleteImage(context, currentItem.Id, type, index, apiClient, true);
});
@ -412,7 +411,7 @@ import 'css!./imageeditor';
const type = this.getAttribute('data-imagetype');
const index = this.getAttribute('data-index');
const newIndex = this.getAttribute('data-newindex');
const apiClient = connectionManager.getApiClient(currentItem.ServerId);
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
moveImage(context, apiClient, currentItem.Id, type, index, newIndex, dom.parentWithClass(this, 'itemsContainer'));
});
}
@ -424,7 +423,7 @@ import 'css!./imageeditor';
loading.show();
import('text!./imageeditor.template.html').then(({default: template}) => {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
const dialogOptions = {
removeOnClose: true

View File

@ -1,6 +1,5 @@
import appHost from 'apphost';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import itemHelper from 'itemHelper';
import appRouter from 'appRouter';
import playbackManager from 'playbackManager';
@ -330,7 +329,7 @@ import actionsheet from 'actionsheet';
function executeCommand(item, id, options) {
const itemId = item.Id;
const serverId = item.ServerId;
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return new Promise(function (resolve, reject) {
switch (id) {

View File

@ -8,7 +8,6 @@
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import loading from 'loading';
import 'emby-select';
import 'listViewStyle';
@ -137,7 +136,7 @@ import 'flexStyles';
}
function loadMediaInfo(itemId, serverId, template) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(item => {
const dialogOptions = {
size: 'small',

View File

@ -7,7 +7,6 @@
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import scrollHelper from 'scrollHelper';
import layoutManager from 'layoutManager';
@ -31,7 +30,7 @@ import 'cardStyle';
let currentSearchResult;
function getApiClient() {
return connectionManager.getApiClient(currentServerId);
return window.connectionManager.getApiClient(currentServerId);
}
function searchForIdentificationResults(page) {

View File

@ -8,7 +8,6 @@
import itemHelper from 'itemHelper';
import mediaInfo from 'mediaInfo';
import indicators from 'indicators';
import connectionManager from 'connectionManager';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import datetime from 'datetime';
@ -77,7 +76,7 @@ import 'emby-playstatebutton';
}
function getImageUrl(item, width) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
let itemId;
const options = {
@ -106,7 +105,7 @@ import 'emby-playstatebutton';
}
function getChannelImageUrl(item, width) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const options = {
maxWidth: width,
type: 'Primary'

View File

@ -4,7 +4,6 @@ import dialogHelper from 'dialogHelper';
import datetime from 'datetime';
import loading from 'loading';
import focusManager from 'focusManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import shell from 'shell';
import 'emby-checkbox';
@ -290,7 +289,7 @@ import 'flexStyles';
}
function getApiClient() {
return connectionManager.getApiClient(currentItem.ServerId);
return window.connectionManager.getApiClient(currentItem.ServerId);
}
function bindAll(elems, eventName, fn) {
@ -370,7 +369,7 @@ import 'flexStyles';
}
function getItem(itemId, serverId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (itemId) {
return apiClient.getItem(apiClient.getCurrentUserId(), itemId);
@ -380,7 +379,7 @@ import 'flexStyles';
}
function getEditorConfig(itemId, serverId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (itemId) {
return apiClient.getJSON(apiClient.getUrl('Items/' + itemId + '/MetadataEditor'));
@ -1068,7 +1067,7 @@ import 'flexStyles';
currentContext = dlg;
init(dlg, connectionManager.getApiClient(serverId));
init(dlg, window.connectionManager.getApiClient(serverId));
reload(dlg, itemId, serverId);
});
@ -1095,7 +1094,7 @@ import 'flexStyles';
currentContext = elem;
init(elem, connectionManager.getApiClient(serverId));
init(elem, window.connectionManager.getApiClient(serverId));
reload(elem, itemId, serverId);
focusManager.autoFocus(elem);

View File

@ -1,7 +1,6 @@
import browser from 'browser';
import appHost from 'apphost';
import loading from 'loading';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import dom from 'dom';
import 'css!./multiSelect';
@ -170,7 +169,7 @@ import 'css!./multiSelect';
}
function showMenuForSelectedItems(e) {
const apiClient = connectionManager.currentApiClient();
const apiClient = window.connectionManager.currentApiClient();
apiClient.getCurrentUser().then(user => {
const menuItems = [];

View File

@ -7,7 +7,6 @@ import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper';
import appHost from 'apphost';
import dom from 'dom';
import connectionManager from 'connectionManager';
import itemContextMenu from 'itemContextMenu';
import 'paper-icon-button-light';
import 'emby-ratingbutton';
@ -452,7 +451,7 @@ import 'emby-ratingbutton';
if (item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
}
@ -460,12 +459,12 @@ import 'emby-ratingbutton';
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -482,12 +481,12 @@ import 'emby-ratingbutton';
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
}
if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;
@ -548,7 +547,7 @@ import 'emby-ratingbutton';
if (nowPlayingItem.Id) {
if (isRefreshing) {
const apiClient = connectionManager.getApiClient(nowPlayingItem.ServerId);
const apiClient = window.connectionManager.getApiClient(nowPlayingItem.ServerId);
apiClient.getItem(apiClient.getCurrentUserId(), nowPlayingItem.Id).then(function (item) {
const userData = item.UserData || {};
const likes = userData.Likes == null ? '' : userData.Likes;

View File

@ -1,7 +1,6 @@
import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper';
import events from 'events';
import connectionManager from 'connectionManager';
/* eslint-disable indent */
// Reports media playback to the device for lock screen control
@ -16,16 +15,16 @@ import connectionManager from 'connectionManager';
} else if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
} else if (options.type === 'Thumb') {
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
} else if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -38,11 +37,11 @@ import connectionManager from 'connectionManager';
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.Id, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.Id, options);
} else if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;

View File

@ -6,7 +6,6 @@ import pluginManager from 'pluginManager';
import PlayQueueManager from 'playQueueManager';
import * as userSettings from 'userSettings';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import loading from 'loading';
import appHost from 'apphost';
import screenfull from 'screenfull';
@ -69,7 +68,7 @@ function reportPlayback(playbackManagerInstance, state, player, reportPlaylist,
addPlaylistToPlaybackReport(playbackManagerInstance, info, player, serverId);
}
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const reportPlaybackPromise = apiClient[method](info);
// Notify that report has been sent
reportPlaybackPromise.then(() => {
@ -106,7 +105,7 @@ function normalizeName(t) {
}
function getItemsForPlayback(serverId, query) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (query.Ids && query.Ids.split(',').length === 1) {
const itemId = query.Ids.split(',');
@ -874,7 +873,7 @@ class PlaybackManager {
const promises = players.filter(displayPlayerIndividually).map(getPlayerTargets);
return Promise.all(promises).then(function (responses) {
return connectionManager.currentApiClient().getCurrentUser().then(function (user) {
return window.connectionManager.currentApiClient().getCurrentUser().then(function (user) {
const targets = [];
targets.push({
@ -1372,7 +1371,7 @@ class PlaybackManager {
function getSavedMaxStreamingBitrate(apiClient, mediaType) {
if (!apiClient) {
// This should hopefully never happen
apiClient = connectionManager.currentApiClient();
apiClient = window.connectionManager.currentApiClient();
}
const endpointInfo = apiClient.getSavedEndpointInfo() || {};
@ -1395,7 +1394,7 @@ class PlaybackManager {
const mediaType = playerData.streamInfo ? playerData.streamInfo.mediaType : null;
const currentItem = self.currentItem(player);
const apiClient = currentItem ? connectionManager.getApiClient(currentItem.ServerId) : connectionManager.currentApiClient();
const apiClient = currentItem ? window.connectionManager.getApiClient(currentItem.ServerId) : window.connectionManager.currentApiClient();
return getSavedMaxStreamingBitrate(apiClient, mediaType);
};
@ -1409,7 +1408,7 @@ class PlaybackManager {
const mediaType = playerData.streamInfo ? playerData.streamInfo.mediaType : null;
const currentItem = self.currentItem(player);
const apiClient = currentItem ? connectionManager.getApiClient(currentItem.ServerId) : connectionManager.currentApiClient();
const apiClient = currentItem ? window.connectionManager.getApiClient(currentItem.ServerId) : window.connectionManager.currentApiClient();
const endpointInfo = apiClient.getSavedEndpointInfo() || {};
return appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType);
@ -1421,7 +1420,7 @@ class PlaybackManager {
return player.setMaxStreamingBitrate(options);
}
const apiClient = connectionManager.getApiClient(self.currentItem(player).ServerId);
const apiClient = window.connectionManager.getApiClient(self.currentItem(player).ServerId);
apiClient.getEndpointInfo().then(function (endpointInfo) {
const playerData = getPlayerData(player);
@ -1691,7 +1690,7 @@ class PlaybackManager {
const subtitleStreamIndex = params.SubtitleStreamIndex == null ? getPlayerData(player).subtitleStreamIndex : params.SubtitleStreamIndex;
let currentMediaSource = self.currentMediaSource(player);
const apiClient = connectionManager.getApiClient(currentItem.ServerId);
const apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
if (ticks) {
ticks = parseInt(ticks);
@ -1847,7 +1846,7 @@ class PlaybackManager {
}, queryOptions));
} else if (firstItem.Type === 'Episode' && items.length === 1 && getPlayer(firstItem, options).supportsProgress !== false) {
promise = new Promise(function (resolve, reject) {
const apiClient = connectionManager.getApiClient(firstItem.ServerId);
const apiClient = window.connectionManager.getApiClient(firstItem.ServerId);
apiClient.getCurrentUser().then(function (user) {
if (!user.Configuration.EnableNextEpisodeAutoPlay || !firstItem.SeriesId) {
@ -2078,7 +2077,7 @@ class PlaybackManager {
return playOther(items, options, user);
}
const apiClient = connectionManager.getApiClient(firstItem.ServerId);
const apiClient = window.connectionManager.getApiClient(firstItem.ServerId);
return getIntros(firstItem, apiClient, options).then(function (introsResult) {
const introItems = introsResult.Items;
@ -2141,14 +2140,14 @@ class PlaybackManager {
const mediaType = item.MediaType;
const onBitrateDetectionFailure = function () {
return playAfterBitrateDetect(getSavedMaxStreamingBitrate(connectionManager.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn);
return playAfterBitrateDetect(getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType), item, playOptions, onPlaybackStartedFn);
};
if (!isServerItem(item) || itemHelper.isLocalItem(item)) {
return onBitrateDetectionFailure();
}
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
apiClient.getEndpointInfo().then(function (endpointInfo) {
if ((mediaType === 'Video' || mediaType === 'Audio') && appSettings.enableAutomaticBitrateDetection(endpointInfo.IsInNetwork, mediaType)) {
return apiClient.detectBitrate().then(function (bitrate) {
@ -2267,7 +2266,7 @@ class PlaybackManager {
return Promise.all([promise, player.getDeviceProfile(item)]).then(function (responses) {
const deviceProfile = responses[1];
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const mediaSourceId = playOptions.mediaSourceId;
const audioStreamIndex = playOptions.audioStreamIndex;
@ -2312,11 +2311,11 @@ class PlaybackManager {
const startPosition = options.startPositionTicks || 0;
const mediaType = options.mediaType || item.MediaType;
const player = getPlayer(item, options);
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
// Call this just to ensure the value is recorded, it is needed with getSavedMaxStreamingBitrate
return apiClient.getEndpointInfo().then(function () {
const maxBitrate = getSavedMaxStreamingBitrate(connectionManager.getApiClient(item.ServerId), mediaType);
const maxBitrate = getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType);
return player.getDeviceProfile(item).then(function (deviceProfile) {
return getPlaybackMediaSource(player, apiClient, deviceProfile, maxBitrate, item, startPosition, options.mediaSourceId, options.audioStreamIndex, options.subtitleStreamIndex).then(function (mediaSource) {
@ -2332,11 +2331,11 @@ class PlaybackManager {
const mediaType = options.mediaType || item.MediaType;
// TODO: Remove the true forceLocalPlayer hack
const player = getPlayer(item, options, true);
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
// Call this just to ensure the value is recorded, it is needed with getSavedMaxStreamingBitrate
return apiClient.getEndpointInfo().then(function () {
const maxBitrate = getSavedMaxStreamingBitrate(connectionManager.getApiClient(item.ServerId), mediaType);
const maxBitrate = getSavedMaxStreamingBitrate(window.connectionManager.getApiClient(item.ServerId), mediaType);
return player.getDeviceProfile(item).then(function (deviceProfile) {
return getPlaybackInfo(player, apiClient, item, deviceProfile, maxBitrate, startPosition, false, null, null, null, null).then(function (playbackInfoResult) {
@ -2720,7 +2719,7 @@ class PlaybackManager {
const queueDirectToPlayer = player && !enableLocalPlaylistManagement(player);
if (queueDirectToPlayer) {
const apiClient = connectionManager.getApiClient(items[0].ServerId);
const apiClient = window.connectionManager.getApiClient(items[0].ServerId);
player.getDeviceProfile(items[0]).then(function (profile) {
setStreamUrls(items, profile, self.getMaxStreamingBitrate(player), apiClient, 0).then(function () {
@ -3170,13 +3169,13 @@ class PlaybackManager {
streamInfo.lastMediaInfoQuery = new Date().getTime();
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (!apiClient.isMinServerVersion('3.2.70.7')) {
return;
}
connectionManager.getApiClient(serverId).getLiveStreamMediaInfo(liveStreamId).then(function (info) {
window.connectionManager.getApiClient(serverId).getLiveStreamMediaInfo(liveStreamId).then(function (info) {
mediaSource.MediaStreams = info.MediaStreams;
events.trigger(player, 'mediastreamschange');
}, function () {
@ -3233,7 +3232,7 @@ class PlaybackManager {
return Promise.reject();
}
const apiClient = connectionManager.getApiClient(nextItem.item.ServerId);
const apiClient = window.connectionManager.getApiClient(nextItem.item.ServerId);
return apiClient.getItem(apiClient.getCurrentUserId(), nextItem.item.Id);
}
@ -3374,7 +3373,7 @@ class PlaybackManager {
return player.playTrailers(item);
}
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const instance = this;
@ -3406,7 +3405,7 @@ class PlaybackManager {
}
getSubtitleUrl(textStream, serverId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return !textStream.IsExternalUrl ? apiClient.getUrl(textStream.DeliveryUrl) : textStream.DeliveryUrl;
}
@ -3486,7 +3485,7 @@ class PlaybackManager {
return player.instantMix(item);
}
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const options = {};
options.UserId = apiClient.getCurrentUserId();

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import actionsheet from 'actionsheet';
import playbackManager from 'playbackManager';
import globalize from 'globalize';
@ -251,7 +250,7 @@ export function show(options) {
return showWithUser(options, player, null);
}
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
var apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
return apiClient.getCurrentUser().then(function (user) {
return showWithUser(options, player, user);
});

View File

@ -5,7 +5,6 @@ import focusManager from 'focusManager';
import qualityoptions from 'qualityoptions';
import globalize from 'globalize';
import loading from 'loading';
import connectionManager from 'connectionManager';
import events from 'events';
import 'emby-select';
import 'emby-checkbox';
@ -258,7 +257,7 @@ import 'emby-checkbox';
function onSubmit(e) {
const self = this;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;
@ -305,7 +304,7 @@ import 'emby-checkbox';
loading.show();
const userId = self.options.userId;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
apiClient.getUser(userId).then(user => {

View File

@ -1,7 +1,6 @@
import events from 'events';
import globalize from 'globalize';
import playbackManager from 'playbackManager';
import connectionManager from 'connectionManager';
import syncPlayManager from 'syncPlayManager';
import playMethodHelper from 'playMethodHelper';
import layoutManager from 'layoutManager';
@ -95,7 +94,7 @@ import 'css!./playerstats';
return Promise.resolve(instance.lastSession);
}
const apiClient = connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
const apiClient = window.connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
return apiClient.getSessions({
deviceId: apiClient.deviceId()
@ -386,7 +385,7 @@ import 'css!./playerstats';
name: 'Original Media Info'
});
var apiClient = connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
var apiClient = window.connectionManager.getApiClient(playbackManager.currentItem(player).ServerId);
if (syncPlayManager.isSyncPlayEnabled() && apiClient.isMinServerVersion('10.6.0')) {
categories.push({
stats: getSyncPlayStats(),

View File

@ -3,7 +3,6 @@ import dialogHelper from 'dialogHelper';
import loading from 'loading';
import layoutManager from 'layoutManager';
import playbackManager from 'playbackManager';
import connectionManager from 'connectionManager';
import * as userSettings from 'userSettings';
import appRouter from 'appRouter';
import globalize from 'globalize';
@ -22,7 +21,7 @@ import 'emby-button';
const panel = dom.parentWithClass(this, 'dialog');
const playlistId = panel.querySelector('#selectPlaylistToAddTo').value;
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
if (playlistId) {
userSettings.set('playlisteditor-lastplaylistid', playlistId);
@ -113,7 +112,7 @@ import 'emby-button';
EnableTotalRecordCount: false
};
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
apiClient.getItems(apiClient.getCurrentUserId(), options).then(result => {
let html = '';

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import dom from 'dom';
import recordingHelper from 'recordingHelper';
import 'paper-icon-button-light';
@ -53,7 +52,7 @@ class RecordingButton {
}
refresh(serverId, itemId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const self = this;
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
self.refreshItem(item);

View File

@ -2,7 +2,6 @@ import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import mediaInfo from 'mediaInfo';
import connectionManager from 'connectionManager';
import require from 'require';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
@ -103,7 +102,7 @@ function renderRecording(context, defaultTimer, program, apiClient, refreshRecor
function reload(context, programId, serverId, refreshRecordingStateOnly) {
loading.show();
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const promise1 = apiClient.getNewLiveTvTimerDefaults({ programId: programId });
const promise2 = apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId());
@ -119,7 +118,7 @@ function reload(context, programId, serverId, refreshRecordingStateOnly) {
function executeCloseAction(action, programId, serverId) {
if (action === 'play') {
import('playbackManager').then(({ default: playbackManager }) => {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) {
playbackManager.play({

View File

@ -1,7 +1,6 @@
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
import 'scrollStyles';
@ -41,7 +40,7 @@ function closeDialog(isDeleted) {
function onSubmit(e) {
const form = this;
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
apiClient.getLiveTvTimer(currentItemId).then(function (item) {
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
@ -61,7 +60,7 @@ function init(context) {
});
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
deleteTimer(apiClient, currentItemId).then(function () {
closeDialog(true);
@ -75,7 +74,7 @@ function reload(context, id) {
loading.show();
currentItemId = id;
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
apiClient.getLiveTvTimer(id).then(function (result) {
renderTimer(context, result, apiClient);
loading.hide();

View File

@ -1,5 +1,4 @@
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import serverNotifications from 'serverNotifications';
import loading from 'loading';
import dom from 'dom';
@ -46,7 +45,7 @@ function loadData(parent, program, apiClient) {
function fetchData(instance) {
const options = instance.options;
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
options.parent.querySelector('.recordingFields').classList.remove('hide');
return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) {
@ -197,7 +196,7 @@ function onRecordChange(e) {
const self = this;
const options = this.options;
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
const button = dom.parentWithTag(e.target, 'BUTTON');
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
@ -236,7 +235,7 @@ function onRecordSeriesChange(e) {
const self = this;
const options = this.options;
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
const button = dom.parentWithTag(e.target, 'BUTTON');
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');

View File

@ -1,6 +1,5 @@
import globalize from 'globalize';
import loading from 'loading';
import connectionManager from 'connectionManager';
/*eslint prefer-const: "error"*/
@ -40,7 +39,7 @@ function cancelTimerWithConfirmation(timerId, serverId) {
}).then(function () {
loading.show();
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
cancelTimer(apiClient, timerId, true).then(resolve, reject);
}, reject);
});
@ -60,7 +59,7 @@ function cancelSeriesTimerWithConfirmation(timerId, serverId) {
}).then(function () {
loading.show();
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SeriesCancelled'));
@ -141,7 +140,7 @@ function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus,
buttons: items
}).then(function (result) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (result === 'canceltimer') {
loading.show();
@ -167,7 +166,7 @@ function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus,
}
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const hasTimer = timerId && timerStatus !== 'Cancelled';
if (seriesTimerId && hasTimer) {
// cancel

View File

@ -1,7 +1,6 @@
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
import datetime from 'datetime';
@ -64,7 +63,7 @@ function closeDialog(isDeleted) {
function onSubmit(e) {
const form = this;
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
@ -92,7 +91,7 @@ function init(context) {
});
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
deleteTimer(apiClient, currentItemId).then(function () {
closeDialog(true);
});
@ -102,7 +101,7 @@ function init(context) {
}
function reload(context, id) {
const apiClient = connectionManager.getApiClient(currentServerId);
const apiClient = window.connectionManager.getApiClient(currentServerId);
loading.show();
if (typeof id === 'string') {

View File

@ -2,7 +2,6 @@ import dom from 'dom';
import dialogHelper from 'dialogHelper';
import loading from 'loading';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import 'emby-input';
import 'emby-checkbox';
@ -66,7 +65,7 @@ function onSubmit(e) {
const dlg = dom.parentWithClass(e.target, 'dialog');
const options = instance.options;
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
const replaceAllMetadata = dlg.querySelector('#selectMetadataRefreshMode').value === 'all';

View File

@ -5,7 +5,6 @@ import imageLoader from 'imageLoader';
import playbackManager from 'playbackManager';
import nowPlayingHelper from 'nowPlayingHelper';
import events from 'events';
import connectionManager from 'connectionManager';
import appHost from 'apphost';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
@ -96,18 +95,18 @@ function seriesImageUrl(item, options) {
options.type = options.type || 'Primary';
if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (options.type === 'Thumb') {
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -120,12 +119,12 @@ function imageUrl(item, options) {
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
}
if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;
@ -216,7 +215,7 @@ function updateNowPlayingInfo(context, state, serverId) {
openAlbum: false,
positionTo: contextButton
};
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
apiClient.getItem(apiClient.getCurrentUserId(), item.Id).then(function (fullItem) {
apiClient.getCurrentUser().then(function (user) {
contextButton.addEventListener('click', function () {

View File

@ -1,6 +1,5 @@
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import cardBuilder from 'cardBuilder';
import appRouter from 'appRouter';
import 'emby-scroller';
@ -606,7 +605,7 @@ class SearchResults {
embed(options.element, this, options);
}
search(value) {
const apiClient = connectionManager.getApiClient(this.options.serverId);
const apiClient = window.connectionManager.getApiClient(this.options.serverId);
search(this, apiClient, this.options.element, value);
}

View File

@ -7,7 +7,6 @@
import playbackManager from 'playbackManager';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import appRouter from 'appRouter';
import globalize from 'globalize';
import dom from 'dom';
@ -81,7 +80,7 @@ import recordingHelper from 'recordingHelper';
const id = button.getAttribute('data-id');
const type = button.getAttribute('data-type');
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (type === 'Timer') {
return apiClient.getLiveTvTimer(id);
@ -111,7 +110,7 @@ import recordingHelper from 'recordingHelper';
}
import('itemContextMenu').then(({default: itemContextMenu}) => {
connectionManager.getApiClient(item.ServerId).getCurrentUser().then(user => {
window.connectionManager.getApiClient(item.ServerId).getCurrentUser().then(user => {
itemContextMenu.show(Object.assign({
item: item,
play: true,
@ -280,7 +279,7 @@ import recordingHelper from 'recordingHelper';
}
function playTrailer(item) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
apiClient.getLocalTrailers(apiClient.getCurrentUserId(), item.Id).then(trailers => {
playbackManager.play({ items: trailers });
@ -288,7 +287,7 @@ import recordingHelper from 'recordingHelper';
}
function editItem(item, serverId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return new Promise((resolve, reject) => {
const serverId = apiClient.serverInfo().Id;

View File

@ -4,7 +4,6 @@
*/
import dialogHelper from 'dialogHelper';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import browser from 'browser';
@ -85,7 +84,7 @@ function getBackdropImageUrl(item, options, apiClient) {
* @returns {string} URL of the item's image.
*/
function getImgUrl(item, user) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const imageOptions = {};
if (item.BackdropImageTags && item.BackdropImageTags.length) {

View File

@ -2,7 +2,6 @@ import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import * as userSettings from 'userSettings';
import connectionManager from 'connectionManager';
import loading from 'loading';
import focusManager from 'focusManager';
import dom from 'dom';
@ -21,7 +20,7 @@ let hasChanges;
function downloadRemoteSubtitles(context, id) {
let url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
let apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({
type: 'POST',
@ -55,7 +54,7 @@ function deleteLocalSubtitle(context, index) {
let itemId = currentItem.Id;
let url = 'Videos/' + itemId + '/Subtitles/' + index;
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
let apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({
@ -243,7 +242,7 @@ function searchForSubtitles(context, language) {
loading.show();
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
let apiClient = window.connectionManager.getApiClient(currentItem.ServerId);
let url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
apiClient.getJSON(url).then(function (results) {
@ -356,7 +355,7 @@ function centerFocus(elem, horiz, on) {
function showEditorInternal(itemId, serverId, template) {
hasChanges = false;
let apiClient = connectionManager.getApiClient(serverId);
let apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
let dialogOptions = {
removeOnClose: true,

View File

@ -4,7 +4,6 @@ import appSettings from 'appSettings';
import focusManager from 'focusManager';
import layoutManager from 'layoutManager';
import loading from 'loading';
import connectionManager from 'connectionManager';
import subtitleAppearanceHelper from 'subtitleAppearanceHelper';
import settingsHelper from 'settingsHelper';
import dom from 'dom';
@ -232,7 +231,7 @@ export class SubtitleSettings {
loading.show();
const userId = self.options.userId;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
apiClient.getUser(userId).then(function (user) {
@ -256,7 +255,7 @@ export class SubtitleSettings {
onSubmit(e) {
const self = this;
const apiClient = connectionManager.getApiClient(self.options.serverId);
const apiClient = window.connectionManager.getApiClient(self.options.serverId);
const userId = self.options.userId;
const userSettings = self.options.userSettings;

View File

@ -1,5 +1,4 @@
import events from 'events';
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import syncPlayManager from 'syncPlayManager';
import loading from 'loading';
@ -172,8 +171,8 @@ export function show (button) {
});
});
const apiClient = connectionManager.currentApiClient();
connectionManager.user(apiClient).then((user) => {
const apiClient = window.connectionManager.currentApiClient();
window.connectionManager.user(apiClient).then((user) => {
if (syncPlayEnabled) {
showLeaveGroupSelection(button, user, apiClient);
} else {

View File

@ -4,7 +4,6 @@
*/
import events from 'events';
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import timeSyncManager from 'timeSyncManager';
import toast from 'toast';
@ -128,7 +127,7 @@ class SyncPlayManager {
// Report ping
if (this.syncEnabled) {
const apiClient = connectionManager.currentApiClient();
const apiClient = window.connectionManager.currentApiClient();
const sessionId = getActivePlayerId();
if (!sessionId) {
@ -660,7 +659,7 @@ class SyncPlayManager {
* Overrides PlaybackManager's unpause method.
*/
playRequest (player) {
var apiClient = connectionManager.currentApiClient();
var apiClient = window.connectionManager.currentApiClient();
apiClient.requestSyncPlayStart();
}
@ -668,7 +667,7 @@ class SyncPlayManager {
* Overrides PlaybackManager's pause method.
*/
pauseRequest (player) {
var apiClient = connectionManager.currentApiClient();
var apiClient = window.connectionManager.currentApiClient();
apiClient.requestSyncPlayPause();
// Pause locally as well, to give the user some little control
playbackManager._localUnpause(player);
@ -678,7 +677,7 @@ class SyncPlayManager {
* Overrides PlaybackManager's seek method.
*/
seekRequest (PositionTicks, player) {
var apiClient = connectionManager.currentApiClient();
var apiClient = window.connectionManager.currentApiClient();
apiClient.requestSyncPlaySeek({
PositionTicks: PositionTicks
});

View File

@ -4,7 +4,6 @@
*/
import events from 'events';
import connectionManager from 'connectionManager';
/**
* Time estimation
@ -114,7 +113,7 @@ class TimeSyncManager {
if (!this.poller) {
this.poller = setTimeout(() => {
this.poller = null;
const apiClient = connectionManager.currentApiClient();
const apiClient = window.connectionManager.currentApiClient();
const requestSent = new Date();
apiClient.getServerTime().then((response) => {
const responseReceived = new Date();

View File

@ -1,6 +1,5 @@
import playbackManager from 'playbackManager';
import * as userSettings from 'userSettings';
import connectionManager from 'connectionManager';
let currentOwnerId;
let currentThemeIds = [];
@ -62,7 +61,7 @@ function loadThemeMedia(item) {
return;
}
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
apiClient.getThemeMedia(apiClient.getCurrentUserId(), item.Id, true).then(function (themeMediaResult) {
const ownerId = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.OwnerId : themeMediaResult.ThemeSongsResult.OwnerId;

View File

@ -1,7 +1,6 @@
import dialogHelper from 'dialogHelper';
import dom from 'dom';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import loading from 'loading';
import browser from 'browser';
@ -163,7 +162,7 @@ function tunerPicker() {
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
}
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
discoverDevices(dlg, apiClient);
if (layoutManager.tv) {

View File

@ -1,6 +1,5 @@
import dom from 'dom';
import playbackManager from 'playbackManager';
import connectionManager from 'connectionManager';
import events from 'events';
import mediaInfo from 'mediaInfo';
import layoutManager from 'layoutManager';
@ -27,7 +26,7 @@ import 'flexStyles';
if (item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
}
@ -35,12 +34,12 @@ import 'flexStyles';
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -53,13 +52,13 @@ import 'flexStyles';
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
}
if (options.type === 'Primary') {
if (item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
}

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import dom from 'dom';
import itemHelper from 'itemHelper';
@ -188,12 +187,12 @@ function markPlayed(link) {
}
function likes(id, serverId, isLiked) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.updateUserItemRating(apiClient.getCurrentUserId(), id, isLiked);
}
function played(id, serverId, isPlayed) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
const method = isPlayed ? 'markPlayed' : 'markUnplayed';
@ -201,13 +200,13 @@ function played(id, serverId, isPlayed) {
}
function favorite(id, serverId, isFavorite) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.updateFavoriteStatus(apiClient.getCurrentUserId(), id, isFavorite);
}
function clearLike(id, serverId) {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return apiClient.clearUserItemRating(apiClient.getCurrentUserId(), id);
}

View File

@ -7,7 +7,6 @@ import globalize from 'globalize';
import * as datefns from 'date-fns';
import dfnshelper from 'dfnshelper';
import loading from 'loading';
import connectionManager from 'connectionManager';
import playMethodHelper from 'playMethodHelper';
import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
@ -60,7 +59,7 @@ import 'emby-itemscontainer';
confirmText: globalize.translate('ButtonSend')
}).then(function (text) {
if (text) {
connectionManager.getApiClient(session.ServerId).sendMessageCommand(session.Id, {
window.connectionManager.getApiClient(session.ServerId).sendMessageCommand(session.Id, {
Text: text,
TimeoutMs: 5e3
});
@ -73,7 +72,7 @@ import 'emby-itemscontainer';
import('actionsheet').then(({default: actionsheet}) => {
const menuItems = [];
if (session.ServerId && session.DeviceId !== connectionManager.deviceId()) {
if (session.ServerId && session.DeviceId !== window.connectionManager.deviceId()) {
menuItems.push({
name: globalize.translate('SendMessage'),
id: 'sendmessage'
@ -123,9 +122,9 @@ import 'emby-itemscontainer';
} else if (btn.classList.contains('btnSessionSendMessage')) {
showSendMessageForm(btn, session);
} else if (btn.classList.contains('btnSessionStop')) {
connectionManager.getApiClient(session.ServerId).sendPlayStateCommand(session.Id, 'Stop');
window.connectionManager.getApiClient(session.ServerId).sendPlayStateCommand(session.Id, 'Stop');
} else if (btn.classList.contains('btnSessionPlayPause') && session.PlayState) {
connectionManager.getApiClient(session.ServerId).sendPlayStateCommand(session.Id, 'PlayPause');
window.connectionManager.getApiClient(session.ServerId).sendPlayStateCommand(session.Id, 'PlayPause');
}
}
}
@ -313,7 +312,7 @@ import 'emby-itemscontainer';
btnCssClass = session.TranscodingInfo && session.TranscodingInfo.TranscodeReasons && session.TranscodingInfo.TranscodeReasons.length ? '' : ' hide';
html += '<button is="paper-icon-button-light" class="sessionCardButton btnSessionInfo paper-icon-button-light ' + btnCssClass + '" title="' + globalize.translate('ViewPlaybackInfo') + '"><span class="material-icons info"></span></button>';
btnCssClass = session.ServerId && session.SupportedCommands.indexOf('DisplayMessage') !== -1 && session.DeviceId !== connectionManager.deviceId() ? '' : ' hide';
btnCssClass = session.ServerId && session.SupportedCommands.indexOf('DisplayMessage') !== -1 && session.DeviceId !== window.connectionManager.deviceId() ? '' : ' hide';
html += '<button is="paper-icon-button-light" class="sessionCardButton btnSessionSendMessage paper-icon-button-light ' + btnCssClass + '" title="' + globalize.translate('SendMessage') + '"><span class="material-icons message"></span></button>';
html += '</div>';
@ -551,7 +550,7 @@ import 'emby-itemscontainer';
row.classList.remove('playingSession');
}
if (session.ServerId && session.SupportedCommands.indexOf('DisplayMessage') !== -1 && session.DeviceId !== connectionManager.deviceId()) {
if (session.ServerId && session.SupportedCommands.indexOf('DisplayMessage') !== -1 && session.DeviceId !== window.connectionManager.deviceId()) {
row.querySelector('.btnSessionSendMessage').classList.remove('hide');
} else {
row.querySelector('.btnSessionSendMessage').classList.add('hide');
@ -565,7 +564,7 @@ import 'emby-itemscontainer';
const btnSessionPlayPause = row.querySelector('.btnSessionPlayPause');
if (session.ServerId && nowPlayingItem && session.SupportsRemoteControl && session.DeviceId !== connectionManager.deviceId()) {
if (session.ServerId && nowPlayingItem && session.SupportsRemoteControl && session.DeviceId !== window.connectionManager.deviceId()) {
btnSessionPlayPause.classList.remove('hide');
row.querySelector('.btnSessionStop').classList.remove('hide');
} else {

View File

@ -2,7 +2,6 @@ import appRouter from 'appRouter';
import cardBuilder from 'cardBuilder';
import dom from 'dom';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import appHost from 'apphost';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
@ -270,7 +269,7 @@ class FavoritesTab {
constructor(view, params) {
this.view = view;
this.params = params;
this.apiClient = connectionManager.currentApiClient();
this.apiClient = window.connectionManager.currentApiClient();
this.sectionsContainer = view.querySelector('.sections');
createSections(this, this.sectionsContainer, this.apiClient);
}

View File

@ -1,6 +1,5 @@
import * as userSettings from 'userSettings';
import loading from 'loading';
import connectionManager from 'connectionManager';
import focusManager from 'focusManager';
import homeSections from 'homeSections';
import 'emby-itemscontainer';
@ -9,7 +8,7 @@ class HomeTab {
constructor(view, params) {
this.view = view;
this.params = params;
this.apiClient = connectionManager.currentApiClient();
this.apiClient = window.connectionManager.currentApiClient();
this.sectionsContainer = view.querySelector('.sections');
view.querySelector('.sections').addEventListener('settingschange', onHomeScreenSettingsChanged.bind(this));
}

View File

@ -3,7 +3,6 @@ import loading from 'loading';
import appRouter from 'appRouter';
import itemShortcuts from 'itemShortcuts';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import * as userSettings from 'userSettings';
import cardBuilder from 'cardBuilder';
import datetime from 'datetime';
@ -564,7 +563,7 @@ function renderDetailPageBackdrop(page, item, apiClient) {
}
function reloadFromItem(instance, page, params, item, user) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
Emby.Page.setTitle('');
@ -797,7 +796,7 @@ function renderNextUp(page, item, user) {
return void section.classList.add('hide');
}
connectionManager.getApiClient(item.ServerId).getNextUpEpisodes({
window.connectionManager.getApiClient(item.ServerId).getNextUpEpisodes({
SeriesId: item.Id,
UserId: user.Id
}).then(function (result) {
@ -1196,7 +1195,7 @@ function renderSimilarItems(page, item, context) {
}
similarCollapsible.classList.remove('hide');
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const options = {
userId: apiClient.getCurrentUserId(),
limit: 12,
@ -1310,7 +1309,7 @@ function renderChildren(page, item) {
}
let promise;
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const userId = apiClient.getCurrentUserId();
if (item.Type == 'Series') {
@ -1549,7 +1548,7 @@ function renderChannelGuide(page, apiClient, item) {
}
function renderSeriesSchedule(page, item) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
apiClient.getLiveTvPrograms({
UserId: apiClient.getCurrentUserId(),
HasAired: false,
@ -1709,7 +1708,7 @@ function renderCollectionItemType(page, parentItem, type, items) {
}
function renderMusicVideos(page, item, user) {
connectionManager.getApiClient(item.ServerId).getItems(user.Id, {
window.connectionManager.getApiClient(item.ServerId).getItems(user.Id, {
SortBy: 'SortName',
SortOrder: 'Ascending',
IncludeItemTypes: 'MusicVideo',
@ -1729,7 +1728,7 @@ function renderMusicVideos(page, item, user) {
}
function renderAdditionalParts(page, item, user) {
connectionManager.getApiClient(item.ServerId).getAdditionalVideoParts(user.Id, item.Id).then(function (result) {
window.connectionManager.getApiClient(item.ServerId).getAdditionalVideoParts(user.Id, item.Id).then(function (result) {
if (result.Items.length) {
page.querySelector('#additionalPartsCollapsible').classList.remove('hide');
const additionalPartsContent = page.querySelector('#additionalPartsContent');
@ -1774,7 +1773,7 @@ function getVideosHtml(items) {
}
function renderSpecials(page, item, user) {
connectionManager.getApiClient(item.ServerId).getSpecialFeatures(user.Id, item.Id).then(function (specials) {
window.connectionManager.getApiClient(item.ServerId).getSpecialFeatures(user.Id, item.Id).then(function (specials) {
const specialsContent = page.querySelector('#specialsContent');
specialsContent.innerHTML = getVideosHtml(specials);
imageLoader.lazyChildren(specialsContent);
@ -1830,7 +1829,7 @@ export default function (view, params) {
function reload(instance, page, params) {
loading.show();
const apiClient = params.serverId ? connectionManager.getApiClient(params.serverId) : ApiClient;
const apiClient = params.serverId ? window.connectionManager.getApiClient(params.serverId) : ApiClient;
Promise.all([getPromise(apiClient, params), apiClient.getCurrentUser()]).then(([item, user]) => {
currentItem = item;
@ -1879,7 +1878,7 @@ export default function (view, params) {
const item = currentItem;
if (item.Type === 'Program') {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
return void apiClient.getLiveTvChannel(item.ChannelId, apiClient.getCurrentUserId()).then(function (channel) {
playbackManager.play({
items: [channel]
@ -1916,7 +1915,7 @@ export default function (view, params) {
function onCancelTimerClick() {
import('recordingHelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelTimer(connectionManager.getApiClient(currentItem.ServerId), currentItem.TimerId).then(function () {
recordingHelper.cancelTimer(window.connectionManager.getApiClient(currentItem.ServerId), currentItem.TimerId).then(function () {
reload(self, view, params);
});
});
@ -1980,7 +1979,7 @@ export default function (view, params) {
let currentItem;
const self = this;
const apiClient = params.serverId ? connectionManager.getApiClient(params.serverId) : ApiClient;
const apiClient = params.serverId ? window.connectionManager.getApiClient(params.serverId) : ApiClient;
view.querySelectorAll('.btnPlay');
bindAll(view, '.btnPlay', 'click', onPlayClick);
bindAll(view, '.btnResume', 'click', onPlayClick);

View File

@ -5,7 +5,6 @@ import * as userSettings from 'userSettings';
import focusManager from 'focusManager';
import cardBuilder from 'cardBuilder';
import loading from 'loading';
import connectionManager from 'connectionManager';
import AlphaNumericShortcuts from 'alphaNumericShortcuts';
import playbackManager from 'playbackManager';
import AlphaPicker from 'alphaPicker';
@ -16,7 +15,7 @@ import 'emby-scroller';
function getInitialLiveTvQuery(instance, params) {
const query = {
UserId: connectionManager.getApiClient(params.serverId).getCurrentUserId(),
UserId: window.connectionManager.getApiClient(params.serverId).getCurrentUserId(),
StartIndex: 0,
Fields: 'ChannelInfo,PrimaryImageAspectRatio',
Limit: 300
@ -232,7 +231,7 @@ import 'emby-scroller';
}
function getItems(instance, params, item, sortBy, startIndex, limit) {
const apiClient = connectionManager.getApiClient(params.serverId);
const apiClient = window.connectionManager.getApiClient(params.serverId);
instance.queryRecursive = false;
if (params.type === 'Recordings') {
@ -333,7 +332,7 @@ import 'emby-scroller';
return Promise.resolve(null);
}
const apiClient = connectionManager.getApiClient(params.serverId);
const apiClient = window.connectionManager.getApiClient(params.serverId);
const itemId = params.genreId || params.musicGenreId || params.studioId || params.personId || params.parentId;
if (itemId) {

View File

@ -7,7 +7,6 @@ import itemHelper from 'itemHelper';
import mediaInfo from 'mediaInfo';
import focusManager from 'focusManager';
import events from 'events';
import connectionManager from 'connectionManager';
import browser from 'browser';
import globalize from 'globalize';
import appHost from 'apphost';
@ -30,18 +29,18 @@ import 'css!assets/css/videoosd';
options.type = options.type || 'Primary';
if (options.type === 'Primary' && item.SeriesPrimaryImageTag) {
options.tag = item.SeriesPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (options.type === 'Thumb') {
if (item.SeriesThumbImageTag) {
options.tag = item.SeriesThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options);
}
if (item.ParentThumbImageTag) {
options.tag = item.ParentThumbImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.ParentThumbItemId, options);
}
}
@ -54,12 +53,12 @@ import 'css!assets/css/videoosd';
if (item.ImageTags && item.ImageTags[options.type]) {
options.tag = item.ImageTags[options.type];
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.PrimaryImageItemId || item.Id, options);
}
if (options.type === 'Primary' && item.AlbumId && item.AlbumPrimaryImageTag) {
options.tag = item.AlbumPrimaryImageTag;
return connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
return window.connectionManager.getApiClient(item.ServerId).getScaledImageUrl(item.AlbumId, options);
}
return null;
@ -118,7 +117,7 @@ import 'css!assets/css/videoosd';
function getDisplayItem(item) {
if (item.Type === 'TvChannel') {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
return apiClient.getItem(apiClient.getCurrentUserId(), item.Id).then(function (refreshedItem) {
return {
originalItem: refreshedItem,
@ -142,7 +141,7 @@ import 'css!assets/css/videoosd';
return void view.querySelector('.btnRecord').classList.add('hide');
}
connectionManager.getApiClient(item.ServerId).getCurrentUser().then(function (user) {
window.connectionManager.getApiClient(item.ServerId).getCurrentUser().then(function (user) {
if (user.Policy.EnableLiveTvManagement) {
import('recordingButton').then(({default: RecordingButton}) => {
if (recordingButtonManager) {
@ -1623,7 +1622,7 @@ import 'css!assets/css/videoosd';
const item = currentItem;
if (item && item.Chapters && item.Chapters.length && item.Chapters[0].ImageTag) {
const html = getChapterBubbleHtml(connectionManager.getApiClient(item.ServerId), item, item.Chapters, ticks);
const html = getChapterBubbleHtml(window.connectionManager.getApiClient(item.ServerId), item, item.Chapters, ticks);
if (html) {
return html;

View File

@ -36,7 +36,7 @@ import 'emby-button';
function submitServer(page) {
loading.show();
const host = page.querySelector('#txtServerHost').value;
ConnectionManager.connectToAddress(host, {
window.connectionManager.connectToAddress(host, {
enableAutoLogin: appSettings.enableAutoLogin()
}).then(function(result) {
handleConnectionResult(page, result);

View File

@ -1,7 +1,6 @@
import appHost from 'apphost';
import appSettings from 'appSettings';
import dom from 'dom';
import connectionManager from 'connectionManager';
import loading from 'loading';
import layoutManager from 'layoutManager';
import libraryMenu from 'libraryMenu';
@ -139,7 +138,7 @@ import 'emby-checkbox';
const serverId = params.serverid;
if (serverId) {
return connectionManager.getOrCreateApiClient(serverId);
return window.connectionManager.getOrCreateApiClient(serverId);
}
return ApiClient;

View File

@ -4,7 +4,6 @@ import layoutManager from 'layoutManager';
import libraryMenu from 'libraryMenu';
import appSettings from 'appSettings';
import focusManager from 'focusManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import actionSheet from 'actionsheet';
import dom from 'dom';
@ -113,7 +112,7 @@ import 'emby-button';
export default function (view, params) {
function connectToServer(server) {
loading.show();
connectionManager.connectToServer(server, {
window.connectionManager.connectToServer(server, {
enableAutoLogin: appSettings.enableAutoLogin()
}).then(function (result) {
loading.hide();
@ -145,7 +144,7 @@ import 'emby-button';
function deleteServer(server) {
loading.show();
connectionManager.deleteServer(server.Id).then(function () {
window.connectionManager.deleteServer(server.Id).then(function () {
loading.hide();
loadServers();
});
@ -187,7 +186,7 @@ import 'emby-button';
function loadServers() {
loading.show();
connectionManager.getAvailableServers().then(onServersRetrieved);
window.connectionManager.getAvailableServers().then(onServersRetrieved);
}
let servers;

View File

@ -1,6 +1,5 @@
import itemShortcuts from 'itemShortcuts';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import imageLoader from 'imageLoader';
import layoutManager from 'layoutManager';
@ -103,7 +102,7 @@ import 'webcomponents';
}
const serverId = el.getAttribute('data-serverid');
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
loading.show();

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import serverNotifications from 'serverNotifications';
import events from 'events';
import globalize from 'globalize';
@ -24,7 +23,7 @@ import EmbyButtonPrototype from 'emby-button';
const button = this;
const id = button.getAttribute('data-id');
const serverId = button.getAttribute('data-serverid');
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (!button.classList.contains('playstatebutton-played')) {
apiClient.markPlayed(apiClient.getCurrentUserId(), id, new Date());

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import serverNotifications from 'serverNotifications';
import events from 'events';
import globalize from 'globalize';
@ -28,7 +27,7 @@ import EmbyButtonPrototype from 'emby-button';
const button = this;
const id = button.getAttribute('data-id');
const serverId = button.getAttribute('data-serverid');
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
let likes = this.getAttribute('data-likes');
const isFavorite = this.getAttribute('data-isfavorite') === 'true';

View File

@ -2,7 +2,6 @@ import events from 'events';
import playbackManager from 'playbackManager';
import pluginManager from 'pluginManager';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import * as userSettings from 'userSettings';
function getMinIdleTime() {
@ -85,7 +84,7 @@ function ScreenSaverManager() {
this.show = function () {
let isLoggedIn;
const apiClient = connectionManager.currentApiClient();
const apiClient = window.connectionManager.currentApiClient();
if (apiClient && apiClient.isLoggedIn()) {
isLoggedIn = true;

View File

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

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import loading from 'loading';
import keyboardnavigation from 'keyboardnavigation';
import dialogHelper from 'dialogHelper';
@ -243,7 +242,7 @@ export class BookPlayer {
};
const serverId = item.ServerId;
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
return new Promise((resolve, reject) => {
import('epubjs').then(({default: epubjs}) => {

View File

@ -221,8 +221,8 @@ function getCachedValue(key) {
return null;
}
events.on(ConnectionManager, 'localusersignedin', clearCache);
events.on(ConnectionManager, 'localusersignedout', clearCache);
events.on(window.connectionManager, 'localusersignedin', clearCache);
events.on(window.connectionManager, 'localusersignedout', clearCache);
export default {
getServerAddress: getServerAddress

View File

@ -1,7 +1,6 @@
import appSettings from 'appSettings';
import * as userSettings from 'userSettings';
import playbackManager from 'playbackManager';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import events from 'events';
import castSenderApiLoader from 'castSenderApiLoader';
@ -325,11 +324,11 @@ class CastPlayer {
let apiClient;
if (message.options && message.options.ServerId) {
apiClient = connectionManager.getApiClient(message.options.ServerId);
apiClient = window.connectionManager.getApiClient(message.options.ServerId);
} else if (message.options && message.options.items && message.options.items.length) {
apiClient = connectionManager.getApiClient(message.options.items[0].ServerId);
apiClient = window.connectionManager.getApiClient(message.options.items[0].ServerId);
} else {
apiClient = connectionManager.currentApiClient();
apiClient = window.connectionManager.currentApiClient();
}
message = Object.assign(message, {
@ -673,7 +672,7 @@ class ChromecastPlayer {
playWithCommand(options, command) {
if (!options.items) {
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
const instance = this;
return apiClient.getItem(apiClient.getCurrentUserId(), options.ids[0]).then(function (item) {
@ -985,7 +984,7 @@ class ChromecastPlayer {
}
shuffle(item) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const userId = apiClient.getCurrentUserId();
const instance = this;
@ -998,7 +997,7 @@ class ChromecastPlayer {
}
instantMix(item) {
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
const userId = apiClient.getCurrentUserId();
const instance = this;
@ -1036,7 +1035,7 @@ class ChromecastPlayer {
}
const instance = this;
const apiClient = connectionManager.getApiClient(options.serverId);
const apiClient = window.connectionManager.getApiClient(options.serverId);
return getItemsForPlayback(apiClient, {
Ids: options.ids.join(',')

View File

@ -5,7 +5,6 @@ import loading from 'loading';
import dom from 'dom';
import playbackManager from 'playbackManager';
import appRouter from 'appRouter';
import connectionManager from 'connectionManager';
import {
bindEventsToHlsPlayer,
destroyHlsPlayer,
@ -325,7 +324,7 @@ function tryRemoveElement(elem) {
console.debug(`prefetching hls playlist: ${hlsPlaylistUrl}`);
return connectionManager.getApiClient(item.ServerId).ajax({
return window.connectionManager.getApiClient(item.ServerId).ajax({
type: 'GET',
url: hlsPlaylistUrl
@ -1036,7 +1035,7 @@ function tryRemoveElement(elem) {
*/
renderSsaAss(videoElement, track, item) {
const attachments = this._currentPlayOptions.mediaSource.MediaAttachments || [];
const apiClient = connectionManager.getApiClient(item);
const apiClient = window.connectionManager.getApiClient(item);
const htmlVideoPlayer = this;
const options = {
video: videoElement,

View File

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

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import globalize from 'globalize';
function showErrorMessage() {
@ -25,7 +24,7 @@ class PlayAccessValidation {
return Promise.resolve();
}
return connectionManager.getApiClient(serverId).getCurrentUser().then(function (user) {
return window.connectionManager.getApiClient(serverId).getCurrentUser().then(function (user) {
if (user.Policy.EnableMediaPlayback) {
return Promise.resolve();
}

View File

@ -1,7 +1,6 @@
import playbackManager from 'playbackManager';
import events from 'events';
import serverNotifications from 'serverNotifications';
import connectionManager from 'connectionManager';
function getActivePlayerId() {
const info = playbackManager.getPlayerInfo();
@ -54,10 +53,10 @@ function getCurrentApiClient(instance) {
const currentServerId = instance.currentServerId;
if (currentServerId) {
return connectionManager.getApiClient(currentServerId);
return window.connectionManager.getApiClient(currentServerId);
}
return connectionManager.currentApiClient();
return window.connectionManager.currentApiClient();
}
function sendCommandByName(instance, name, options) {

View File

@ -1,12 +1,11 @@
import * as userSettings from 'userSettings';
import skinManager from 'skinManager';
import connectionManager from 'connectionManager';
import events from 'events';
// Set the default theme when loading
skinManager.setTheme(userSettings.theme());
// Set the user's prefered theme when signing in
events.on(connectionManager, 'localusersignedin', function (e, user) {
events.on(window.connectionManager, 'localusersignedin', function (e, user) {
skinManager.setTheme(userSettings.theme());
});

View File

@ -48,7 +48,7 @@ export function onServerChanged(userId, accessToken, apiClient) {
}
export function logout() {
ConnectionManager.logout().then(function () {
window.connectionManager.logout().then(function () {
let loginPage;
if (AppInfo.isNativeApp) {

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import confirm from 'confirm';
import appRouter from 'appRouter';
import globalize from 'globalize';
@ -15,7 +14,7 @@ export function deleteItem(options) {
const item = options.item;
const parentId = item.SeasonId || item.SeriesId || item.ParentId;
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
return confirm({

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import listView from 'listView';
import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
@ -358,7 +357,7 @@ function getItemsFunction(options, item) {
query.Fields += ',' + fields;
}
const apiClient = connectionManager.getApiClient(item.ServerId);
const apiClient = window.connectionManager.getApiClient(item.ServerId);
if (query.IncludeItemTypes === 'MusicArtist') {
query.IncludeItemTypes = null;

View File

@ -1,7 +1,6 @@
import dom from 'dom';
import layoutManager from 'layoutManager';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import events from 'events';
import viewManager from 'viewManager';
import appRouter from 'appRouter';
@ -57,10 +56,10 @@ import 'flexStyles';
function getCurrentApiClient() {
if (currentUser && currentUser.localUser) {
return connectionManager.getApiClient(currentUser.localUser.ServerId);
return window.connectionManager.getApiClient(currentUser.localUser.ServerId);
}
return connectionManager.currentApiClient();
return window.connectionManager.currentApiClient();
}
function lazyLoadViewMenuBarImages() {
@ -749,7 +748,7 @@ import 'flexStyles';
}
if (requiresUserRefresh) {
connectionManager.user(getCurrentApiClient()).then(updateUserInHeader);
window.connectionManager.user(getCurrentApiClient()).then(updateUserInHeader);
}
}
@ -791,7 +790,7 @@ import 'flexStyles';
if (user) {
Promise.resolve(user);
} else {
connectionManager.user(getCurrentApiClient()).then(function (user) {
window.connectionManager.user(getCurrentApiClient()).then(function (user) {
refreshLibraryInfoInDrawer(user);
updateLibraryMenu(user.localUser);
});
@ -957,8 +956,8 @@ import 'flexStyles';
renderHeader();
events.on(connectionManager, 'localusersignedin', function (e, user) {
const currentApiClient = connectionManager.getApiClient(user.ServerId);
events.on(window.connectionManager, 'localusersignedin', function (e, user) {
const currentApiClient = window.connectionManager.getApiClient(user.ServerId);
currentDrawerType = null;
currentUser = {
@ -967,13 +966,13 @@ import 'flexStyles';
loadNavDrawer();
connectionManager.user(currentApiClient).then(function (user) {
window.connectionManager.user(currentApiClient).then(function (user) {
currentUser = user;
updateUserInHeader(user);
});
});
events.on(connectionManager, 'localusersignedout', function () {
events.on(window.connectionManager, 'localusersignedout', function () {
currentUser = {};
updateUserInHeader();
});

View File

@ -1,4 +1,3 @@
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import syncPlayManager from 'syncPlayManager';
import events from 'events';
@ -208,8 +207,8 @@ function bindEvents(apiClient) {
events.on(apiClient, 'message', onMessageReceived);
}
connectionManager.getApiClients().forEach(bindEvents);
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
window.connectionManager.getApiClients().forEach(bindEvents);
events.on(window.connectionManager, 'apiclientcreated', function (e, newApiClient) {
bindEvents(newApiClient);
});

View File

@ -56,30 +56,23 @@ window.pageIdOn = function(eventName, id, fn) {
var AppInfo = {};
function initClient() {
function defineConnectionManager(connectionManager) {
window.ConnectionManager = connectionManager;
define('connectionManager', [], function () {
return connectionManager;
});
}
function bindConnectionManagerEvents(connectionManager, events, userSettings) {
window.Events = events;
connectionManager.currentApiClient = function () {
window.connectionManager.currentApiClient = function () {
if (!localApiClient) {
var server = connectionManager.getLastUsedServer();
var server = window.connectionManager.getLastUsedServer();
if (server) {
localApiClient = connectionManager.getApiClient(server.Id);
localApiClient = window.connectionManager.getApiClient(server.Id);
}
}
return localApiClient;
};
connectionManager.onLocalUserSignedIn = function (user) {
localApiClient = connectionManager.getApiClient(user.ServerId);
window.connectionManager.onLocalUserSignedIn = function (user) {
localApiClient = window.connectionManager.getApiClient(user.ServerId);
window.ApiClient = localApiClient;
return userSettings.setUserInfo(user.Id, localApiClient);
};
@ -99,10 +92,9 @@ function initClient() {
return Promise.all(promises).then(function (responses) {
var capabilities = Dashboard.capabilities(appHost);
var connectionManager = new ConnectionManager(credentialProviderInstance, appHost.appName(), appHost.appVersion(), appHost.deviceName(), appHost.deviceId(), capabilities);
window.connectionManager = new ConnectionManager(credentialProviderInstance, appHost.appName(), appHost.appVersion(), appHost.deviceName(), appHost.deviceId(), capabilities);
defineConnectionManager(connectionManager);
bindConnectionManagerEvents(connectionManager, events, userSettings);
bindConnectionManagerEvents(window.connectionManager, events, userSettings);
if (!AppInfo.isNativeApp) {
console.debug('loading ApiClient singleton');
@ -115,7 +107,7 @@ function initClient() {
apiClient.enableAutomaticNetworking = false;
apiClient.manualAddressOnly = true;
connectionManager.addApiClient(apiClient);
window.connectionManager.addApiClient(apiClient);
window.ApiClient = apiClient;
localApiClient = apiClient;
@ -225,8 +217,8 @@ function initClient() {
require(['autoFocuser'], function(autoFocuser) {
autoFocuser.enable();
});
require(['globalize', 'connectionManager', 'events'], function (globalize, connectionManager, events) {
events.on(connectionManager, 'localusersignedin', globalize.updateCurrentCulture);
require(['globalize', 'events'], function (globalize, events) {
events.on(window.connectionManager, 'localusersignedin', globalize.updateCurrentCulture);
});
});
});
@ -374,7 +366,7 @@ function initClient() {
require(['playerSelectionMenu']);
var apiClient = window.ConnectionManager && window.ConnectionManager.currentApiClient();
var apiClient = window.connectionManager && window.connectionManager.currentApiClient();
if (apiClient) {
fetch(apiClient.getUrl('Branding/Css'))
.then(function(response) {
@ -675,9 +667,6 @@ function initClient() {
define('mouseManager', [scriptsPath + '/mouseManager'], returnFirstDependency);
define('scrollManager', [componentsPath + '/scrollManager'], returnFirstDependency);
define('autoFocuser', [componentsPath + '/autoFocuser'], returnFirstDependency);
define('connectionManager', [], function () {
return ConnectionManager;
});
define('apiClientResolver', [], function () {
return function () {
return window.ApiClient;

View File

@ -1,13 +1,12 @@
import events from 'events';
import serverNotifications from 'serverNotifications';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
import 'emby-button';
export default function (options) {
function pollTasks() {
connectionManager.getApiClient(serverId).getScheduledTasks({
window.connectionManager.getApiClient(serverId).getScheduledTasks({
IsEnabled: true
}).then(updateTasks);
}
@ -64,7 +63,7 @@ export default function (options) {
}
function onScheduledTaskMessageConfirmed(id) {
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
window.connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
}
function onButtonClick() {
@ -82,13 +81,13 @@ export default function (options) {
const serverId = ApiClient.serverId();
function onPollIntervalFired() {
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
if (!window.connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
pollTasks();
}
}
function startInterval() {
const apiClient = connectionManager.getApiClient(serverId);
const apiClient = window.connectionManager.getApiClient(serverId);
if (pollInterval) {
clearInterval(pollInterval);
@ -98,7 +97,7 @@ export default function (options) {
}
function stopInterval() {
connectionManager.getApiClient(serverId).sendMessage('ScheduledTasksInfoStop');
window.connectionManager.getApiClient(serverId).sendMessage('ScheduledTasksInfoStop');
if (pollInterval) {
clearInterval(pollInterval);