From d9bb55a2a9ffc71b677b5cc9bdd90018560d7bef Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Sat, 1 Oct 2022 02:39:12 -0400 Subject: [PATCH 1/3] Move SyncPlay initialization to plugin --- .../syncPlay/core/players/PlayerFactory.js | 4 +- src/config.json | 3 +- src/index.jsx | 31 +----------- src/plugins/syncPlay/plugin.ts | 49 +++++++++++++++++++ 4 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 src/plugins/syncPlay/plugin.ts diff --git a/src/components/syncPlay/core/players/PlayerFactory.js b/src/components/syncPlay/core/players/PlayerFactory.js index 1de9aa5126..ab4170c9e7 100644 --- a/src/components/syncPlay/core/players/PlayerFactory.js +++ b/src/components/syncPlay/core/players/PlayerFactory.js @@ -16,7 +16,7 @@ class PlayerFactory { /** * Registers a wrapper to the list of players that can be managed. - * @param {GenericPlayer} wrapperClass The wrapper to register. + * @param {typeof GenericPlayer} wrapperClass The wrapper to register. */ registerWrapper(wrapperClass) { console.debug('SyncPlay WrapperFactory registerWrapper:', wrapperClass.type); @@ -25,7 +25,7 @@ class PlayerFactory { /** * Sets the default player wrapper. - * @param {GenericPlayer} wrapperClass The wrapper. + * @param {typeof GenericPlayer} wrapperClass The wrapper. */ setDefaultWrapper(wrapperClass) { console.debug('SyncPlay WrapperFactory setDefaultWrapper:', wrapperClass.type); diff --git a/src/config.json b/src/config.json index 5b24006a48..3d80b1efec 100644 --- a/src/config.json +++ b/src/config.json @@ -44,6 +44,7 @@ "pdfPlayer/plugin", "logoScreensaver/plugin", "sessionPlayer/plugin", - "chromecastPlayer/plugin" + "chromecastPlayer/plugin", + "syncPlay/plugin" ] } diff --git a/src/index.jsx b/src/index.jsx index 7ca4b92a24..e177a281e1 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -35,11 +35,6 @@ import './legacy/domParserTextHtml'; import './legacy/focusPreventScroll'; import './legacy/htmlMediaElement'; import './legacy/vendorStyles'; -import SyncPlay from './components/syncPlay/core'; -import { playbackManager } from './components/playback/playbackmanager'; -import SyncPlayNoActivePlayer from './components/syncPlay/ui/players/NoActivePlayer'; -import SyncPlayHtmlVideoPlayer from './components/syncPlay/ui/players/HtmlVideoPlayer'; -import SyncPlayHtmlAudioPlayer from './components/syncPlay/ui/players/HtmlAudioPlayer'; import { currentSettings } from './scripts/settings/userSettings'; import taskButton from './scripts/taskbutton'; import { HistoryRouter } from './components/HistoryRouter.tsx'; @@ -102,10 +97,7 @@ function onGlobalizeInit() { import('./assets/css/librarybrowser.scss'); - loadPlugins().then(function () { - initSyncPlay(); - onAppReady(); - }); + loadPlugins().then(onAppReady); } function loadPlugins() { @@ -137,27 +129,6 @@ function loadPlugins() { }); } -function initSyncPlay() { - // Register player wrappers. - SyncPlay.PlayerFactory.setDefaultWrapper(SyncPlayNoActivePlayer); - SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlVideoPlayer); - SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlAudioPlayer); - - // Listen for player changes. - Events.on(playbackManager, 'playerchange', (event, newPlayer, newTarget, oldPlayer) => { - SyncPlay.Manager.onPlayerChange(newPlayer, newTarget, oldPlayer); - }); - - // Start SyncPlay. - const apiClient = ServerConnections.currentApiClient(); - if (apiClient) SyncPlay.Manager.init(apiClient); - - // FIXME: Multiple apiClients? - Events.on(ServerConnections, 'apiclientcreated', (e, newApiClient) => SyncPlay.Manager.init(newApiClient)); - Events.on(ServerConnections, 'localusersignedin', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient())); - Events.on(ServerConnections, 'localusersignedout', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient())); -} - async function onAppReady() { console.debug('begin onAppReady'); diff --git a/src/plugins/syncPlay/plugin.ts b/src/plugins/syncPlay/plugin.ts new file mode 100644 index 0000000000..f4cd78a3c5 --- /dev/null +++ b/src/plugins/syncPlay/plugin.ts @@ -0,0 +1,49 @@ +import { Events } from 'jellyfin-apiclient'; + +import { playbackManager } from '../../components/playback/playbackmanager'; +import ServerConnections from '../../components/ServerConnections'; +import SyncPlay from '../../components/syncPlay/core'; +import SyncPlayNoActivePlayer from '../../components/syncPlay/ui/players/NoActivePlayer'; +import SyncPlayHtmlVideoPlayer from '../../components/syncPlay/ui/players/HtmlVideoPlayer'; +import SyncPlayHtmlAudioPlayer from '../../components/syncPlay/ui/players/HtmlAudioPlayer'; + +class SyncPlayPlugin { + name: string; + id: string; + type: string; + priority: number; + + constructor() { + this.name = 'SyncPlay Plugin'; + this.id = 'syncplay'; + // NOTE: This should probably be a "mediaplayer" so the playback manager can handle playback logic, but + // SyncPlay needs refactored so it does not have an independent playback manager. + this.type = 'syncplay'; + this.priority = 1; + + this.init(); + } + + init() { + // Register player wrappers. + SyncPlay.PlayerFactory.setDefaultWrapper(SyncPlayNoActivePlayer); + SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlVideoPlayer); + SyncPlay.PlayerFactory.registerWrapper(SyncPlayHtmlAudioPlayer); + + // Listen for player changes. + Events.on(playbackManager, 'playerchange', (_, newPlayer) => { + SyncPlay.Manager.onPlayerChange(newPlayer); + }); + + // Start SyncPlay. + const apiClient = ServerConnections.currentApiClient(); + if (apiClient) SyncPlay.Manager.init(apiClient); + + // FIXME: Multiple apiClients? + Events.on(ServerConnections, 'apiclientcreated', (_, newApiClient) => SyncPlay.Manager.init(newApiClient)); + Events.on(ServerConnections, 'localusersignedin', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient())); + Events.on(ServerConnections, 'localusersignedout', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient())); + } +} + +export default SyncPlayPlugin; From 496508ee4d4a9791387a28367d37bcebd84bc49a Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Sat, 1 Oct 2022 02:57:30 -0400 Subject: [PATCH 2/3] Move SyncPlay code to plugin directory --- src/components/playerstats/playerstats.js | 2 +- src/components/playlisteditor/playlisteditor.js | 2 +- src/controllers/playback/video/index.js | 2 +- .../syncPlay/core/Controller.js | 0 src/{components => plugins}/syncPlay/core/Helper.js | 0 src/{components => plugins}/syncPlay/core/Manager.js | 2 +- .../syncPlay/core/PlaybackCore.js | 0 .../syncPlay/core/QueueCore.js | 2 +- .../syncPlay/core/Settings.js | 0 src/{components => plugins}/syncPlay/core/index.js | 0 .../syncPlay/core/players/GenericPlayer.js | 0 .../syncPlay/core/players/PlayerFactory.js | 0 .../syncPlay/core/timeSync/TimeSync.js | 0 .../syncPlay/core/timeSync/TimeSyncCore.js | 0 .../syncPlay/core/timeSync/TimeSyncServer.js | 0 src/plugins/syncPlay/plugin.ts | 8 ++++---- .../syncPlay/ui/groupSelectionMenu.js | 8 ++++---- .../syncPlay/ui/groupSelectionMenu.scss | 0 .../syncPlay/ui/playbackPermissionManager.js | 2 +- .../syncPlay/ui/players/HtmlAudioPlayer.js | 0 .../syncPlay/ui/players/HtmlVideoPlayer.js | 0 .../syncPlay/ui/players/NoActivePlayer.js | 2 +- .../syncPlay/ui/players/QueueManager.js | 0 .../syncPlay/ui/settings/SettingsEditor.js | 12 ++++++------ .../syncPlay/ui/settings/editor.html | 0 src/scripts/libraryMenu.js | 2 +- src/scripts/serverNotifications.js | 2 +- 27 files changed, 23 insertions(+), 23 deletions(-) rename src/{components => plugins}/syncPlay/core/Controller.js (100%) rename src/{components => plugins}/syncPlay/core/Helper.js (100%) rename src/{components => plugins}/syncPlay/core/Manager.js (99%) rename src/{components => plugins}/syncPlay/core/PlaybackCore.js (100%) rename src/{components => plugins}/syncPlay/core/QueueCore.js (99%) rename src/{components => plugins}/syncPlay/core/Settings.js (100%) rename src/{components => plugins}/syncPlay/core/index.js (100%) rename src/{components => plugins}/syncPlay/core/players/GenericPlayer.js (100%) rename src/{components => plugins}/syncPlay/core/players/PlayerFactory.js (100%) rename src/{components => plugins}/syncPlay/core/timeSync/TimeSync.js (100%) rename src/{components => plugins}/syncPlay/core/timeSync/TimeSyncCore.js (100%) rename src/{components => plugins}/syncPlay/core/timeSync/TimeSyncServer.js (100%) rename src/{components => plugins}/syncPlay/ui/groupSelectionMenu.js (96%) rename src/{components => plugins}/syncPlay/ui/groupSelectionMenu.scss (100%) rename src/{components => plugins}/syncPlay/ui/playbackPermissionManager.js (96%) rename src/{components => plugins}/syncPlay/ui/players/HtmlAudioPlayer.js (100%) rename src/{components => plugins}/syncPlay/ui/players/HtmlVideoPlayer.js (100%) rename src/{components => plugins}/syncPlay/ui/players/NoActivePlayer.js (99%) rename src/{components => plugins}/syncPlay/ui/players/QueueManager.js (100%) rename src/{components => plugins}/syncPlay/ui/settings/SettingsEditor.js (93%) rename src/{components => plugins}/syncPlay/ui/settings/editor.html (100%) diff --git a/src/components/playerstats/playerstats.js b/src/components/playerstats/playerstats.js index df15dac19d..225b0650c7 100644 --- a/src/components/playerstats/playerstats.js +++ b/src/components/playerstats/playerstats.js @@ -4,7 +4,7 @@ import globalize from '../../scripts/globalize'; import layoutManager from '../layoutManager'; import { playbackManager } from '../playback/playbackmanager'; import playMethodHelper from '../playback/playmethodhelper'; -import SyncPlay from '../../components/syncPlay/core'; +import SyncPlay from '../../plugins/syncPlay/core'; import './playerstats.scss'; import ServerConnections from '../ServerConnections'; diff --git a/src/components/playlisteditor/playlisteditor.js b/src/components/playlisteditor/playlisteditor.js index 440685fd9c..70ae0644d1 100644 --- a/src/components/playlisteditor/playlisteditor.js +++ b/src/components/playlisteditor/playlisteditor.js @@ -4,7 +4,7 @@ import dialogHelper from '../dialogHelper/dialogHelper'; import loading from '../loading/loading'; import layoutManager from '../layoutManager'; import { playbackManager } from '../playback/playbackmanager'; -import SyncPlay from '../../components/syncPlay/core'; +import SyncPlay from '../../plugins/syncPlay/core'; import * as userSettings from '../../scripts/settings/userSettings'; import { appRouter } from '../appRouter'; import globalize from '../../scripts/globalize'; diff --git a/src/controllers/playback/video/index.js b/src/controllers/playback/video/index.js index d5da82b740..a51bff1d50 100644 --- a/src/controllers/playback/video/index.js +++ b/src/controllers/playback/video/index.js @@ -1,6 +1,6 @@ import escapeHtml from 'escape-html'; import { playbackManager } from '../../../components/playback/playbackmanager'; -import SyncPlay from '../../../components/syncPlay/core'; +import SyncPlay from '../../../plugins/syncPlay/core'; import browser from '../../../scripts/browser'; import dom from '../../../scripts/dom'; import inputManager from '../../../scripts/inputManager'; diff --git a/src/components/syncPlay/core/Controller.js b/src/plugins/syncPlay/core/Controller.js similarity index 100% rename from src/components/syncPlay/core/Controller.js rename to src/plugins/syncPlay/core/Controller.js diff --git a/src/components/syncPlay/core/Helper.js b/src/plugins/syncPlay/core/Helper.js similarity index 100% rename from src/components/syncPlay/core/Helper.js rename to src/plugins/syncPlay/core/Helper.js diff --git a/src/components/syncPlay/core/Manager.js b/src/plugins/syncPlay/core/Manager.js similarity index 99% rename from src/components/syncPlay/core/Manager.js rename to src/plugins/syncPlay/core/Manager.js index 16640c1df2..c41fe14fb7 100644 --- a/src/components/syncPlay/core/Manager.js +++ b/src/plugins/syncPlay/core/Manager.js @@ -9,7 +9,7 @@ import TimeSyncCore from './timeSync/TimeSyncCore'; import PlaybackCore from './PlaybackCore'; import QueueCore from './QueueCore'; import Controller from './Controller'; -import toast from '../../toast/toast'; +import toast from '../../../components/toast/toast'; import globalize from '../../../scripts/globalize'; /** diff --git a/src/components/syncPlay/core/PlaybackCore.js b/src/plugins/syncPlay/core/PlaybackCore.js similarity index 100% rename from src/components/syncPlay/core/PlaybackCore.js rename to src/plugins/syncPlay/core/PlaybackCore.js diff --git a/src/components/syncPlay/core/QueueCore.js b/src/plugins/syncPlay/core/QueueCore.js similarity index 99% rename from src/components/syncPlay/core/QueueCore.js rename to src/plugins/syncPlay/core/QueueCore.js index 81feac0aca..cdf1d56a1e 100644 --- a/src/components/syncPlay/core/QueueCore.js +++ b/src/plugins/syncPlay/core/QueueCore.js @@ -4,7 +4,7 @@ */ import globalize from '../../../scripts/globalize'; -import toast from '../../toast/toast'; +import toast from '../../../components/toast/toast'; import * as Helper from './Helper'; /** diff --git a/src/components/syncPlay/core/Settings.js b/src/plugins/syncPlay/core/Settings.js similarity index 100% rename from src/components/syncPlay/core/Settings.js rename to src/plugins/syncPlay/core/Settings.js diff --git a/src/components/syncPlay/core/index.js b/src/plugins/syncPlay/core/index.js similarity index 100% rename from src/components/syncPlay/core/index.js rename to src/plugins/syncPlay/core/index.js diff --git a/src/components/syncPlay/core/players/GenericPlayer.js b/src/plugins/syncPlay/core/players/GenericPlayer.js similarity index 100% rename from src/components/syncPlay/core/players/GenericPlayer.js rename to src/plugins/syncPlay/core/players/GenericPlayer.js diff --git a/src/components/syncPlay/core/players/PlayerFactory.js b/src/plugins/syncPlay/core/players/PlayerFactory.js similarity index 100% rename from src/components/syncPlay/core/players/PlayerFactory.js rename to src/plugins/syncPlay/core/players/PlayerFactory.js diff --git a/src/components/syncPlay/core/timeSync/TimeSync.js b/src/plugins/syncPlay/core/timeSync/TimeSync.js similarity index 100% rename from src/components/syncPlay/core/timeSync/TimeSync.js rename to src/plugins/syncPlay/core/timeSync/TimeSync.js diff --git a/src/components/syncPlay/core/timeSync/TimeSyncCore.js b/src/plugins/syncPlay/core/timeSync/TimeSyncCore.js similarity index 100% rename from src/components/syncPlay/core/timeSync/TimeSyncCore.js rename to src/plugins/syncPlay/core/timeSync/TimeSyncCore.js diff --git a/src/components/syncPlay/core/timeSync/TimeSyncServer.js b/src/plugins/syncPlay/core/timeSync/TimeSyncServer.js similarity index 100% rename from src/components/syncPlay/core/timeSync/TimeSyncServer.js rename to src/plugins/syncPlay/core/timeSync/TimeSyncServer.js diff --git a/src/plugins/syncPlay/plugin.ts b/src/plugins/syncPlay/plugin.ts index f4cd78a3c5..e1b7c29cd6 100644 --- a/src/plugins/syncPlay/plugin.ts +++ b/src/plugins/syncPlay/plugin.ts @@ -2,10 +2,10 @@ import { Events } from 'jellyfin-apiclient'; import { playbackManager } from '../../components/playback/playbackmanager'; import ServerConnections from '../../components/ServerConnections'; -import SyncPlay from '../../components/syncPlay/core'; -import SyncPlayNoActivePlayer from '../../components/syncPlay/ui/players/NoActivePlayer'; -import SyncPlayHtmlVideoPlayer from '../../components/syncPlay/ui/players/HtmlVideoPlayer'; -import SyncPlayHtmlAudioPlayer from '../../components/syncPlay/ui/players/HtmlAudioPlayer'; +import SyncPlay from './core'; +import SyncPlayNoActivePlayer from './ui/players/NoActivePlayer'; +import SyncPlayHtmlVideoPlayer from './ui/players/HtmlVideoPlayer'; +import SyncPlayHtmlAudioPlayer from './ui/players/HtmlAudioPlayer'; class SyncPlayPlugin { name: string; diff --git a/src/components/syncPlay/ui/groupSelectionMenu.js b/src/plugins/syncPlay/ui/groupSelectionMenu.js similarity index 96% rename from src/components/syncPlay/ui/groupSelectionMenu.js rename to src/plugins/syncPlay/ui/groupSelectionMenu.js index 807899773f..106ee8e42d 100644 --- a/src/components/syncPlay/ui/groupSelectionMenu.js +++ b/src/plugins/syncPlay/ui/groupSelectionMenu.js @@ -1,12 +1,12 @@ import { Events } from 'jellyfin-apiclient'; import SyncPlay from '../core'; import SyncPlaySettingsEditor from './settings/SettingsEditor'; -import loading from '../../loading/loading'; -import toast from '../../toast/toast'; -import actionsheet from '../../actionSheet/actionSheet'; +import loading from '../../../components/loading/loading'; +import toast from '../../../components/toast/toast'; +import actionsheet from '../../../components/actionSheet/actionSheet'; import globalize from '../../../scripts/globalize'; import playbackPermissionManager from './playbackPermissionManager'; -import ServerConnections from '../../ServerConnections'; +import ServerConnections from '../../../components/ServerConnections'; import './groupSelectionMenu.scss'; /** diff --git a/src/components/syncPlay/ui/groupSelectionMenu.scss b/src/plugins/syncPlay/ui/groupSelectionMenu.scss similarity index 100% rename from src/components/syncPlay/ui/groupSelectionMenu.scss rename to src/plugins/syncPlay/ui/groupSelectionMenu.scss diff --git a/src/components/syncPlay/ui/playbackPermissionManager.js b/src/plugins/syncPlay/ui/playbackPermissionManager.js similarity index 96% rename from src/components/syncPlay/ui/playbackPermissionManager.js rename to src/plugins/syncPlay/ui/playbackPermissionManager.js index 2a70d7370a..816b57bca9 100644 --- a/src/components/syncPlay/ui/playbackPermissionManager.js +++ b/src/plugins/syncPlay/ui/playbackPermissionManager.js @@ -1,4 +1,4 @@ -import { appHost } from '../../apphost'; +import { appHost } from '../../../components/apphost'; /** * Creates an audio element that plays a silent sound. diff --git a/src/components/syncPlay/ui/players/HtmlAudioPlayer.js b/src/plugins/syncPlay/ui/players/HtmlAudioPlayer.js similarity index 100% rename from src/components/syncPlay/ui/players/HtmlAudioPlayer.js rename to src/plugins/syncPlay/ui/players/HtmlAudioPlayer.js diff --git a/src/components/syncPlay/ui/players/HtmlVideoPlayer.js b/src/plugins/syncPlay/ui/players/HtmlVideoPlayer.js similarity index 100% rename from src/components/syncPlay/ui/players/HtmlVideoPlayer.js rename to src/plugins/syncPlay/ui/players/HtmlVideoPlayer.js diff --git a/src/components/syncPlay/ui/players/NoActivePlayer.js b/src/plugins/syncPlay/ui/players/NoActivePlayer.js similarity index 99% rename from src/components/syncPlay/ui/players/NoActivePlayer.js rename to src/plugins/syncPlay/ui/players/NoActivePlayer.js index 699d31517b..c5f528938d 100644 --- a/src/components/syncPlay/ui/players/NoActivePlayer.js +++ b/src/plugins/syncPlay/ui/players/NoActivePlayer.js @@ -3,7 +3,7 @@ * @module components/syncPlay/ui/players/NoActivePlayer */ -import { playbackManager } from '../../../playback/playbackmanager'; +import { playbackManager } from '../../../../components/playback/playbackmanager'; import SyncPlay from '../../core'; import QueueManager from './QueueManager'; diff --git a/src/components/syncPlay/ui/players/QueueManager.js b/src/plugins/syncPlay/ui/players/QueueManager.js similarity index 100% rename from src/components/syncPlay/ui/players/QueueManager.js rename to src/plugins/syncPlay/ui/players/QueueManager.js diff --git a/src/components/syncPlay/ui/settings/SettingsEditor.js b/src/plugins/syncPlay/ui/settings/SettingsEditor.js similarity index 93% rename from src/components/syncPlay/ui/settings/SettingsEditor.js rename to src/plugins/syncPlay/ui/settings/SettingsEditor.js index 3f90725145..ede7e267a3 100644 --- a/src/components/syncPlay/ui/settings/SettingsEditor.js +++ b/src/plugins/syncPlay/ui/settings/SettingsEditor.js @@ -6,10 +6,10 @@ import { Events } from 'jellyfin-apiclient'; import SyncPlay from '../../core'; import { setSetting } from '../../core/Settings'; -import dialogHelper from '../../../dialogHelper/dialogHelper'; -import layoutManager from '../../../layoutManager'; -import loading from '../../../loading/loading'; -import toast from '../../../toast/toast'; +import dialogHelper from '../../../../components/dialogHelper/dialogHelper'; +import layoutManager from '../../../../components/layoutManager'; +import loading from '../../../../components/loading/loading'; +import toast from '../../../../components/toast/toast'; import globalize from '../../../../scripts/globalize'; import 'material-design-icons-iconfont'; @@ -18,8 +18,8 @@ import '../../../../elements/emby-select/emby-select'; import '../../../../elements/emby-button/emby-button'; import '../../../../elements/emby-button/paper-icon-button-light'; import '../../../../elements/emby-checkbox/emby-checkbox'; -import '../../../listview/listview.scss'; -import '../../../formdialog.scss'; +import '../../../../components/listview/listview.scss'; +import '../../../../components/formdialog.scss'; function centerFocus(elem, horiz, on) { import('../../../../scripts/scrollHelper').then((scrollHelper) => { diff --git a/src/components/syncPlay/ui/settings/editor.html b/src/plugins/syncPlay/ui/settings/editor.html similarity index 100% rename from src/components/syncPlay/ui/settings/editor.html rename to src/plugins/syncPlay/ui/settings/editor.html diff --git a/src/scripts/libraryMenu.js b/src/scripts/libraryMenu.js index 81f819f809..5cf5be305d 100644 --- a/src/scripts/libraryMenu.js +++ b/src/scripts/libraryMenu.js @@ -9,7 +9,7 @@ import viewManager from '../components/viewManager/viewManager'; import { appRouter } from '../components/appRouter'; import { appHost } from '../components/apphost'; import { playbackManager } from '../components/playback/playbackmanager'; -import groupSelectionMenu from '../components/syncPlay/ui/groupSelectionMenu'; +import groupSelectionMenu from '../plugins/syncPlay/ui/groupSelectionMenu'; import browser from './browser'; import globalize from './globalize'; import imageHelper from './imagehelper'; diff --git a/src/scripts/serverNotifications.js b/src/scripts/serverNotifications.js index 73a10bcbde..e8b58ce0fe 100644 --- a/src/scripts/serverNotifications.js +++ b/src/scripts/serverNotifications.js @@ -1,5 +1,5 @@ import { playbackManager } from '../components/playback/playbackmanager'; -import SyncPlay from '../components/syncPlay/core'; +import SyncPlay from '../plugins/syncPlay/core'; import { Events } from 'jellyfin-apiclient'; import inputManager from '../scripts/inputManager'; import focusManager from '../components/focusManager'; From 3a07d34884faedad8f392bf23c877c7dc399a2a0 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Sun, 2 Oct 2022 03:55:35 -0400 Subject: [PATCH 3/3] Add check that SyncPlay plugin is enabled --- src/scripts/libraryMenu.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scripts/libraryMenu.js b/src/scripts/libraryMenu.js index 5cf5be305d..ce1918e196 100644 --- a/src/scripts/libraryMenu.js +++ b/src/scripts/libraryMenu.js @@ -9,6 +9,7 @@ import viewManager from '../components/viewManager/viewManager'; import { appRouter } from '../components/appRouter'; import { appHost } from '../components/apphost'; import { playbackManager } from '../components/playback/playbackmanager'; +import { pluginManager } from '../components/pluginManager'; import groupSelectionMenu from '../plugins/syncPlay/ui/groupSelectionMenu'; import browser from './browser'; import globalize from './globalize'; @@ -154,8 +155,14 @@ import '../assets/css/flexstyles.scss'; const policy = user.Policy ? user.Policy : user.localUser.Policy; - const apiClient = getCurrentApiClient(); - if (headerSyncButton && policy?.SyncPlayAccess !== 'None' && apiClient.isMinServerVersion('10.6.0')) { + if ( + // Button is present + headerSyncButton + // SyncPlay plugin is loaded + && pluginManager.plugins.filter(plugin => plugin.id === 'syncplay').length > 0 + // SyncPlay enabled for user + && policy?.SyncPlayAccess !== 'None' + ) { headerSyncButton.classList.remove('hide'); } } else {