From 802bb3a7577334e48b269aaa75b0f887be2cbf7e Mon Sep 17 00:00:00 2001 From: Sparky Date: Sat, 23 Feb 2019 10:29:42 -0500 Subject: [PATCH 1/6] Make types more consistent There is no instance I can find where these values are ever *actually* strings. Changing them to boolean improves consistency. --- .../emby-webcomponents/browserdeviceprofile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bower_components/emby-webcomponents/browserdeviceprofile.js b/src/bower_components/emby-webcomponents/browserdeviceprofile.js index 7b37a0cdb1..ad5237fde8 100644 --- a/src/bower_components/emby-webcomponents/browserdeviceprofile.js +++ b/src/bower_components/emby-webcomponents/browserdeviceprofile.js @@ -751,7 +751,7 @@ define(['browser'], function (browser) { Condition: 'Equals', Property: 'IsSecondaryAudio', Value: 'false', - IsRequired: 'false' + IsRequired: false }); } @@ -780,7 +780,7 @@ define(['browser'], function (browser) { Condition: 'Equals', Property: 'IsSecondaryAudio', Value: 'false', - IsRequired: 'false' + IsRequired: false } ] }); @@ -913,4 +913,4 @@ define(['browser'], function (browser) { return profile; }; -}); \ No newline at end of file +}); From fa8eb4f34d984a37e83dbdde6ffc9575b2de29ea Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 26 Feb 2019 02:39:58 +0900 Subject: [PATCH 2/6] method deminification --- src/scripts/pluginspage.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/scripts/pluginspage.js b/src/scripts/pluginspage.js index 69583403e8..37fcfd423a 100644 --- a/src/scripts/pluginspage.js +++ b/src/scripts/pluginspage.js @@ -32,12 +32,34 @@ define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-linkbut function getPluginCardHtml(plugin, pluginConfigurationPages) { var configPage = pluginConfigurationPages.filter(function(pluginConfigurationPage) { return pluginConfigurationPage.PluginId == plugin.Id - })[0], - html = "", - disallowPlugins = !Dashboard.allowPluginPages(plugin.Id), - configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null, - href = configPage && !disallowPlugins ? configPageUrl : null; - return html += "
", html += '
', html += '
', html += '
', html += href ? '' : configPageUrl ? disallowPlugins ? '
' : '", html += '
', html += '
', html += '', html += "
", html += "
", html += configPage ? configPage.DisplayName || plugin.Name : plugin.Name, html += "
", html += "
", html += plugin.Version, html += "
", html += "
", html += "
", html += "
" + })[0]; + var html = ""; + var disallowPlugins = !Dashboard.allowPluginPages(plugin.Id); + var configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null; + var href = configPage && !disallowPlugins ? configPageUrl : null; + + html += "
"; + html += '
'; + html += '
'; + html += '
'; + html += href ? '' : configPageUrl ? disallowPlugins ? '
' : '"; + html += '
'; + html += '
'; + html += ''; + html += "
"; + html += "
"; + html += configPage ? configPage.DisplayName || plugin.Name : plugin.Name; + html += "
"; + html += "
"; + html += plugin.Version; + html += "
"; + html += "
"; + html += "
"; + html += "
"; + return html; } function renderPlugins(page, plugins, showNoPluginsMessage) { From 2dd44178fa9dbe1f8239fd5be926ffa8b563b018 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 26 Feb 2019 02:56:18 +0900 Subject: [PATCH 3/6] remove plugin configuration block for android devices --- src/scripts/librarymenu.js | 17 +++++++---------- src/scripts/pluginspage.js | 8 +++----- src/scripts/site.js | 3 --- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/scripts/librarymenu.js b/src/scripts/librarymenu.js index 8d65f9420b..145ae42479 100644 --- a/src/scripts/librarymenu.js +++ b/src/scripts/librarymenu.js @@ -386,16 +386,13 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", " function addPluginPagesToMainMenu(links, pluginItems, section) { for (var i = 0, length = pluginItems.length; i < length; i++) { var pluginItem = pluginItems[i]; - - if (Dashboard.allowPluginPages(pluginItem.PluginId)) { - if (pluginItem.EnableInMainMenu && pluginItem.MenuSection === section) { - links.push({ - name: pluginItem.DisplayName, - icon: pluginItem.MenuIcon || "folder", - href: Dashboard.getConfigurationPageUrl(pluginItem.Name), - pageUrls: [Dashboard.getConfigurationPageUrl(pluginItem.Name)] - }); - } + if (pluginItem.EnableInMainMenu && pluginItem.MenuSection === section) { + links.push({ + name: pluginItem.DisplayName, + icon: pluginItem.MenuIcon || "folder", + href: Dashboard.getConfigurationPageUrl(pluginItem.Name), + pageUrls: [Dashboard.getConfigurationPageUrl(pluginItem.Name)] + }); } } } diff --git a/src/scripts/pluginspage.js b/src/scripts/pluginspage.js index 37fcfd423a..6fd82f4a2d 100644 --- a/src/scripts/pluginspage.js +++ b/src/scripts/pluginspage.js @@ -33,18 +33,16 @@ define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-linkbut var configPage = pluginConfigurationPages.filter(function(pluginConfigurationPage) { return pluginConfigurationPage.PluginId == plugin.Id })[0]; - var html = ""; - var disallowPlugins = !Dashboard.allowPluginPages(plugin.Id); var configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null; - var href = configPage && !disallowPlugins ? configPageUrl : null; + var html = ""; html += "
"; html += '
'; html += '
'; html += '
'; - html += href ? '' : configPageUrl ? disallowPlugins ? '
' : '"; html += '
'; html += '
'; diff --git a/src/scripts/site.js b/src/scripts/site.js index 573464ec2c..c387952a9f 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -32,9 +32,6 @@ function pageIdOn(eventName, id, fn) { }) } var Dashboard = { - allowPluginPages: function(pluginId) { - return true; - }, getCurrentUser: function() { return window.ApiClient.getCurrentUser(!1) }, From 3f7ca1d915e98621af92455e365e83ae2197164f Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 26 Feb 2019 03:15:12 +0900 Subject: [PATCH 4/6] clean up plugin catalog page --- src/scripts/plugincatalogpage.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/scripts/plugincatalogpage.js b/src/scripts/plugincatalogpage.js index ed237a02d4..40d57560b5 100644 --- a/src/scripts/plugincatalogpage.js +++ b/src/scripts/plugincatalogpage.js @@ -3,7 +3,6 @@ define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", " function reloadList(page) { loading.show(); - query.IsAppStoreSafe = true; var promise1 = ApiClient.getAvailablePlugins(query); var promise2 = ApiClient.getInstalledPlugins(); Promise.all([promise1, promise2]).then(function (responses) { @@ -16,13 +15,8 @@ define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", " }); } - function populateList(options) { - populateListInternal(options); - } - function getHeaderText(category) { category = category.replace(" ", ""); - if ("Channel" === category) { category = "Channels"; } else if ("Theme" === category) { @@ -36,11 +30,7 @@ define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", " return globalize.translate(category); } - function isUserInstalledPlugin(plugin) { - return -1 === ["02528C96-F727-44D7-BE87-9EEF040758C3", "0277E613-3EC0-4360-A3DE-F8AF0AABB5E9", "4DCB591C-0FA2-4C5D-A7E5-DABE37164C8B"].indexOf(plugin.guid); - } - - function populateListInternal(options) { + function populateList(options) { var availablePlugins = options.availablePlugins; var installedPlugins = options.installedPlugins; var allPlugins = availablePlugins.filter(function (plugin) { @@ -113,7 +103,7 @@ define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", " } return 0; - }).filter(isUserInstalledPlugin); + }); html += '
'; var limit = screen.availWidth >= 1920 ? 15 : 12; @@ -215,11 +205,14 @@ define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", " var query = { TargetSystems: "Server", + IsAppStoreSafe: true, IsAdult: false }; + window.PluginCatalog = { renderCatalog: populateList }; + return function (view, params) { view.querySelector("#selectSystem").addEventListener("change", function () { query.TargetSystems = this.value; From 32a8e89420308ebce74031d659cf9db5bd3ca106 Mon Sep 17 00:00:00 2001 From: dkanada Date: Wed, 27 Feb 2019 06:11:42 +0900 Subject: [PATCH 5/6] use normal method for getAvailablePlugins --- src/scripts/site.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/scripts/site.js b/src/scripts/site.js index c387952a9f..2d6c15b1eb 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -150,14 +150,8 @@ var Dashboard = { ! function() { "use strict"; - function initializeApiClient(apiClient) { - "cordova" !== self.appMode && "android" !== self.appMode || (apiClient.getAvailablePlugins = function() { - return Promise.resolve([]) - }) - } - function onApiClientCreated(e, newApiClient) { - initializeApiClient(newApiClient), window.$ && ($.ajax = newApiClient.ajax) + window.$ && ($.ajax = newApiClient.ajax) } function defineConnectionManager(connectionManager) { From bb118a5ae8e09361a46a79721de8119734e17f76 Mon Sep 17 00:00:00 2001 From: Vasily Date: Tue, 26 Feb 2019 21:12:58 +0000 Subject: [PATCH 6/6] add suggested changes from code review Co-Authored-By: dkanada --- src/scripts/pluginspage.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scripts/pluginspage.js b/src/scripts/pluginspage.js index 6fd82f4a2d..6264f012e0 100644 --- a/src/scripts/pluginspage.js +++ b/src/scripts/pluginspage.js @@ -41,7 +41,12 @@ define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-linkbut html += '"; html += '
'; @@ -137,4 +142,4 @@ define(["loading", "libraryMenu", "dom", "globalize", "cardStyle", "emby-linkbut }), window.PluginsPage = { renderPlugins: renderPlugins } -}); \ No newline at end of file +});