From 42ac558a17dde06fed9f0be9736dd63eb91a8caa Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 6 Aug 2020 11:41:18 +0100 Subject: [PATCH 1/5] Migration of notification to ES6 module --- package.json | 1 + src/components/notifications/notifications.js | 404 +++++++++--------- 2 files changed, 203 insertions(+), 202 deletions(-) diff --git a/package.json b/package.json index 1d7cf770d3..f729f60723 100644 --- a/package.json +++ b/package.json @@ -135,6 +135,7 @@ "src/components/metadataEditor/metadataEditor.js", "src/components/metadataEditor/personEditor.js", "src/components/multiSelect/multiSelect.js", + "src/components/notifications/notifications.js", "src/components/nowPlayingBar/nowPlayingBar.js", "src/components/playback/brightnessosd.js", "src/components/playback/mediasession.js", diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index 0bf270f2a1..020d9953ef 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -1,181 +1,181 @@ -define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'require'], function (serverNotifications, playbackManager, events, globalize, require) { - 'use strict'; +import serverNotifications from 'serverNotifications'; +import playbackManager from 'playbackManager'; +import events from 'events'; +import globalize from 'globalize'; - playbackManager = playbackManager.default || playbackManager; +function onOneDocumentClick() { + document.removeEventListener('click', onOneDocumentClick); + document.removeEventListener('keydown', onOneDocumentClick); - function onOneDocumentClick() { - document.removeEventListener('click', onOneDocumentClick); - document.removeEventListener('keydown', onOneDocumentClick); - - // don't request notification permissions if they're already granted or denied - if (window.Notification && window.Notification.permission === 'default') { - /* eslint-disable-next-line compat/compat */ - Notification.requestPermission(); - } - } - - document.addEventListener('click', onOneDocumentClick); - document.addEventListener('keydown', onOneDocumentClick); - - var serviceWorkerRegistration; - - function closeAfter(notification, timeoutMs) { - setTimeout(function () { - if (notification.close) { - notification.close(); - } else if (notification.cancel) { - notification.cancel(); - } - }, timeoutMs); - } - - function resetRegistration() { + // don't request notification permissions if they're already granted or denied + if (window.Notification && window.Notification.permission === 'default') { /* eslint-disable-next-line compat/compat */ - var serviceWorker = navigator.serviceWorker; - if (serviceWorker) { - serviceWorker.ready.then(function (registration) { - serviceWorkerRegistration = registration; - }); + Notification.requestPermission(); + } +} + +document.addEventListener('click', onOneDocumentClick); +document.addEventListener('keydown', onOneDocumentClick); + +let serviceWorkerRegistration; + +function closeAfter(notification, timeoutMs) { + setTimeout(function () { + if (notification.close) { + notification.close(); + } else if (notification.cancel) { + notification.cancel(); + } + }, timeoutMs); +} + +function resetRegistration() { + /* eslint-disable-next-line compat/compat */ + let serviceWorker = navigator.serviceWorker; + if (serviceWorker) { + serviceWorker.ready.then(function (registration) { + serviceWorkerRegistration = registration; + }); + } +} + +resetRegistration(); + +function showPersistentNotification(title, options, timeoutMs) { + serviceWorkerRegistration.showNotification(title, options); +} + +function showNonPersistentNotification(title, options, timeoutMs) { + try { + let notif = new Notification(title, options); /* eslint-disable-line compat/compat */ + + if (notif.show) { + notif.show(); + } + + if (timeoutMs) { + closeAfter(notif, timeoutMs); + } + } catch (err) { + if (options.actions) { + options.actions = []; + showNonPersistentNotification(title, options, timeoutMs); + } else { + throw err; } } +} + +function showNotification(options, timeoutMs, apiClient) { + let title = options.title; + + options.data = options.data || {}; + options.data.serverId = apiClient.serverInfo().Id; + options.icon = options.icon || getIconUrl(); + options.badge = options.badge || getIconUrl('badge.png'); resetRegistration(); - function showPersistentNotification(title, options, timeoutMs) { - serviceWorkerRegistration.showNotification(title, options); + if (serviceWorkerRegistration) { + showPersistentNotification(title, options, timeoutMs); + return; } - function showNonPersistentNotification(title, options, timeoutMs) { - try { - var notif = new Notification(title, options); /* eslint-disable-line compat/compat */ + showNonPersistentNotification(title, options, timeoutMs); +} - if (notif.show) { - notif.show(); - } - - if (timeoutMs) { - closeAfter(notif, timeoutMs); - } - } catch (err) { - if (options.actions) { - options.actions = []; - showNonPersistentNotification(title, options, timeoutMs); - } else { - throw err; - } - } +function showNewItemNotification(item, apiClient) { + if (playbackManager.isPlayingLocally(['Video'])) { + return; } - function showNotification(options, timeoutMs, apiClient) { - var title = options.title; + let body = item.Name; - options.data = options.data || {}; - options.data.serverId = apiClient.serverInfo().Id; - options.icon = options.icon || getIconUrl(); - options.badge = options.badge || getIconUrl('badge.png'); - - resetRegistration(); - - if (serviceWorkerRegistration) { - showPersistentNotification(title, options, timeoutMs); - return; - } - - showNonPersistentNotification(title, options, timeoutMs); + if (item.SeriesName) { + body = item.SeriesName + ' - ' + body; } - function showNewItemNotification(item, apiClient) { - if (playbackManager.isPlayingLocally(['Video'])) { - return; - } + let notification = { + title: 'New ' + item.Type, + body: body, + vibrate: true, + tag: 'newItem' + item.Id, + data: {} + }; - var body = item.Name; + let imageTags = item.ImageTags || {}; - if (item.SeriesName) { - body = item.SeriesName + ' - ' + body; - } - - var notification = { - title: 'New ' + item.Type, - body: body, - vibrate: true, - tag: 'newItem' + item.Id, - data: {} - }; - - var imageTags = item.ImageTags || {}; - - if (imageTags.Primary) { - notification.icon = apiClient.getScaledImageUrl(item.Id, { - width: 80, - tag: imageTags.Primary, - type: 'Primary' - }); - } - - showNotification(notification, 15000, apiClient); - } - - function onLibraryChanged(data, apiClient) { - var newItems = data.ItemsAdded; - - if (!newItems.length) { - return; - } - - // Don't put a massive number of Id's onto the query string - if (newItems.length > 12) { - newItems.length = 12; - } - - apiClient.getItems(apiClient.getCurrentUserId(), { - - Recursive: true, - Limit: 3, - Filters: 'IsNotFolder', - SortBy: 'DateCreated', - SortOrder: 'Descending', - Ids: newItems.join(','), - MediaTypes: 'Audio,Video', - EnableTotalRecordCount: false - - }).then(function (result) { - var items = result.Items; - - for (var i = 0, length = items.length ; i < length; i++) { - showNewItemNotification(items[i], apiClient); - } + if (imageTags.Primary) { + notification.icon = apiClient.getScaledImageUrl(item.Id, { + width: 80, + tag: imageTags.Primary, + type: 'Primary' }); } - function getIconUrl(name) { - name = name || 'notificationicon.png'; - return require.toUrl('.').split('?')[0] + '/' + name; + showNotification(notification, 15000, apiClient); +} + +function onLibraryChanged(data, apiClient) { + let newItems = data.ItemsAdded; + + if (!newItems.length) { + return; } - function showPackageInstallNotification(apiClient, installation, status) { - apiClient.getCurrentUser().then(function (user) { - if (!user.Policy.IsAdministrator) { - return; - } + // Don't put a massive number of Id's onto the query string + if (newItems.length > 12) { + newItems.length = 12; + } - var notification = { - tag: 'install' + installation.Id, - data: {} - }; + apiClient.getItems(apiClient.getCurrentUserId(), { - if (status === 'completed') { - notification.title = globalize.translate('PackageInstallCompleted', installation.Name, installation.Version); - notification.vibrate = true; - } else if (status === 'cancelled') { - notification.title = globalize.translate('PackageInstallCancelled', installation.Name, installation.Version); - } else if (status === 'failed') { - notification.title = globalize.translate('PackageInstallFailed', installation.Name, installation.Version); - notification.vibrate = true; - } else if (status === 'progress') { - notification.title = globalize.translate('InstallingPackage', installation.Name, installation.Version); + Recursive: true, + Limit: 3, + Filters: 'IsNotFolder', + SortBy: 'DateCreated', + SortOrder: 'Descending', + Ids: newItems.join(','), + MediaTypes: 'Audio,Video', + EnableTotalRecordCount: false - notification.actions = + }).then(function (result) { + let items = result.Items; + + for (const item of items) { + showNewItemNotification(item, apiClient); + } + }); +} + +function getIconUrl(name) { + name = name || 'notificationicon.png'; + return './components/notifications/' + name; +} + +function showPackageInstallNotification(apiClient, installation, status) { + apiClient.getCurrentUser().then(function (user) { + if (!user.Policy.IsAdministrator) { + return; + } + + let notification = { + tag: 'install' + installation.Id, + data: {} + }; + + if (status === 'completed') { + notification.title = globalize.translate('PackageInstallCompleted', installation.Name, installation.Version); + notification.vibrate = true; + } else if (status === 'cancelled') { + notification.title = globalize.translate('PackageInstallCancelled', installation.Name, installation.Version); + } else if (status === 'failed') { + notification.title = globalize.translate('PackageInstallFailed', installation.Name, installation.Version); + notification.vibrate = true; + } else if (status === 'progress') { + notification.title = globalize.translate('InstallingPackage', installation.Name, installation.Version); + + notification.actions = [ { action: 'cancel-install', @@ -184,67 +184,67 @@ define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'requir } ]; - notification.data.id = installation.id; - } + notification.data.id = installation.id; + } - if (status === 'progress') { - var percentComplete = Math.round(installation.PercentComplete || 0); + if (status === 'progress') { + let percentComplete = Math.round(installation.PercentComplete || 0); - notification.body = percentComplete + '% complete.'; - } + notification.body = percentComplete + '% complete.'; + } - var timeout = status === 'cancelled' ? 5000 : 0; + let timeout = status === 'cancelled' ? 5000 : 0; - showNotification(notification, timeout, apiClient); - }); - } - - events.on(serverNotifications, 'LibraryChanged', function (e, apiClient, data) { - onLibraryChanged(data, apiClient); + showNotification(notification, timeout, apiClient); }); +} - events.on(serverNotifications, 'PackageInstallationCompleted', function (e, apiClient, data) { - showPackageInstallNotification(apiClient, data, 'completed'); - }); +events.on(serverNotifications, 'LibraryChanged', function (e, apiClient, data) { + onLibraryChanged(data, apiClient); +}); - events.on(serverNotifications, 'PackageInstallationFailed', function (e, apiClient, data) { - showPackageInstallNotification(apiClient, data, 'failed'); - }); +events.on(serverNotifications, 'PackageInstallationCompleted', function (e, apiClient, data) { + showPackageInstallNotification(apiClient, data, 'completed'); +}); - events.on(serverNotifications, 'PackageInstallationCancelled', function (e, apiClient, data) { - showPackageInstallNotification(apiClient, data, 'cancelled'); - }); +events.on(serverNotifications, 'PackageInstallationFailed', function (e, apiClient, data) { + showPackageInstallNotification(apiClient, data, 'failed'); +}); - events.on(serverNotifications, 'PackageInstalling', function (e, apiClient, data) { - showPackageInstallNotification(apiClient, data, 'progress'); - }); +events.on(serverNotifications, 'PackageInstallationCancelled', function (e, apiClient, data) { + showPackageInstallNotification(apiClient, data, 'cancelled'); +}); - events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, data) { - var serverId = apiClient.serverInfo().Id; - var notification = { - tag: 'restart' + serverId, - title: globalize.translate('ServerNameIsShuttingDown', apiClient.serverInfo().Name) - }; - showNotification(notification, 0, apiClient); - }); +events.on(serverNotifications, 'PackageInstalling', function (e, apiClient, data) { + showPackageInstallNotification(apiClient, data, 'progress'); +}); - events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data) { - var serverId = apiClient.serverInfo().Id; - var notification = { - tag: 'restart' + serverId, - title: globalize.translate('ServerNameIsRestarting', apiClient.serverInfo().Name) - }; - showNotification(notification, 0, apiClient); - }); +events.on(serverNotifications, 'ServerShuttingDown', function (e, apiClient, data) { + let serverId = apiClient.serverInfo().Id; + let notification = { + tag: 'restart' + serverId, + title: globalize.translate('ServerNameIsShuttingDown', apiClient.serverInfo().Name) + }; + showNotification(notification, 0, apiClient); +}); - events.on(serverNotifications, 'RestartRequired', function (e, apiClient) { - var serverId = apiClient.serverInfo().Id; - var notification = { - tag: 'restart' + serverId, - title: globalize.translate('PleaseRestartServerName', apiClient.serverInfo().Name) - }; +events.on(serverNotifications, 'ServerRestarting', function (e, apiClient, data) { + let serverId = apiClient.serverInfo().Id; + let notification = { + tag: 'restart' + serverId, + title: globalize.translate('ServerNameIsRestarting', apiClient.serverInfo().Name) + }; + showNotification(notification, 0, apiClient); +}); - notification.actions = +events.on(serverNotifications, 'RestartRequired', function (e, apiClient) { + let serverId = apiClient.serverInfo().Id; + let notification = { + tag: 'restart' + serverId, + title: globalize.translate('PleaseRestartServerName', apiClient.serverInfo().Name) + }; + + notification.actions = [ { action: 'restart', @@ -253,6 +253,6 @@ define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'requir } ]; - showNotification(notification, 0, apiClient); - }); + showNotification(notification, 0, apiClient); }); + From e813f64cd2d92ce9f8069b8f53ac9231b5e5b970 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 6 Aug 2020 11:41:45 +0100 Subject: [PATCH 2/5] Migration of themeMediaPlayer to ES6 module --- package.json | 1 + src/components/themeMediaPlayer.js | 175 ++++++++++++++--------------- 2 files changed, 88 insertions(+), 88 deletions(-) diff --git a/package.json b/package.json index f729f60723..aceef6b67e 100644 --- a/package.json +++ b/package.json @@ -167,6 +167,7 @@ "src/components/syncPlay/playbackPermissionManager.js", "src/components/syncPlay/syncPlayManager.js", "src/components/syncPlay/timeSyncManager.js", + "src/components/themeMediaPlayer.js", "src/components/toast/toast.js", "src/components/upnextdialog/upnextdialog.js", "src/components/viewContainer.js", diff --git a/src/components/themeMediaPlayer.js b/src/components/themeMediaPlayer.js index 60f0986884..4ee9e0c910 100644 --- a/src/components/themeMediaPlayer.js +++ b/src/components/themeMediaPlayer.js @@ -1,103 +1,102 @@ -define(['playbackManager', 'userSettings', 'connectionManager'], function (playbackManager, userSettings, connectionManager) { - 'use strict'; +import playbackManager from 'playbackManager'; +import userSettings from 'userSettings'; +import connectionManager from 'connectionManager'; - playbackManager = playbackManager.default || playbackManager; +let currentOwnerId; +let currentThemeIds = []; - var currentOwnerId; - var currentThemeIds = []; +function playThemeMedia(items, ownerId) { + const currentThemeItems = items.filter(function (i) { + return enabled(i.MediaType); + }); - function playThemeMedia(items, ownerId) { - var currentThemeItems = items.filter(function (i) { - return enabled(i.MediaType); + if (currentThemeItems.length) { + // Stop if a theme song from another ownerId + // Leave it alone if anything else (e.g user playing a movie) + if (!currentOwnerId && playbackManager.isPlaying()) { + return; + } + + currentThemeIds = currentThemeItems.map(function (i) { + return i.Id; }); - if (currentThemeItems.length) { - // Stop if a theme song from another ownerId - // Leave it alone if anything else (e.g user playing a movie) - if (!currentOwnerId && playbackManager.isPlaying()) { - return; - } - - currentThemeIds = currentThemeItems.map(function (i) { - return i.Id; - }); - - playbackManager.play({ - items: currentThemeItems, - fullscreen: false, - enableRemotePlayers: false - }).then(function () { - currentOwnerId = ownerId; - }); - } else { - stopIfPlaying(); - } - } - - function stopIfPlaying() { - if (currentOwnerId) { - playbackManager.stop(); - } - - currentOwnerId = null; - } - - function enabled(mediaType) { - if (mediaType === 'Video') { - return userSettings.enableThemeVideos(); - } - - return userSettings.enableThemeSongs(); - } - - var excludeTypes = ['CollectionFolder', 'UserView', 'Program', 'SeriesTimer', 'Person', 'TvChannel', 'Channel']; - - function loadThemeMedia(item) { - if (item.CollectionType) { - stopIfPlaying(); - return; - } - - if (excludeTypes.indexOf(item.Type) !== -1) { - stopIfPlaying(); - return; - } - - var apiClient = connectionManager.getApiClient(item.ServerId); - apiClient.getThemeMedia(apiClient.getCurrentUserId(), item.Id, true).then(function (themeMediaResult) { - var ownerId = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.OwnerId : themeMediaResult.ThemeSongsResult.OwnerId; - - if (ownerId !== currentOwnerId) { - var items = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.Items : themeMediaResult.ThemeSongsResult.Items; - - playThemeMedia(items, ownerId); - } + playbackManager.play({ + items: currentThemeItems, + fullscreen: false, + enableRemotePlayers: false + }).then(function () { + currentOwnerId = ownerId; }); + } else { + stopIfPlaying(); + } +} + +function stopIfPlaying() { + if (currentOwnerId) { + playbackManager.stop(); } - document.addEventListener('viewshow', function (e) { - var state = e.detail.state || {}; - var item = state.item; + currentOwnerId = null; +} - if (item && item.ServerId) { - loadThemeMedia(item); - return; - } +function enabled(mediaType) { + if (mediaType === 'Video') { + return userSettings.enableThemeVideos(); + } - var viewOptions = e.detail.options || {}; + return userSettings.enableThemeSongs(); +} - if (viewOptions.supportsThemeMedia) { - // Do nothing here, allow it to keep playing - } else { - playThemeMedia([], null); - } - }, true); +const excludeTypes = ['CollectionFolder', 'UserView', 'Program', 'SeriesTimer', 'Person', 'TvChannel', 'Channel']; - Events.on(playbackManager, 'playbackstart', function (e, player) { - var item = playbackManager.currentItem(player); - // User played something manually - if (currentThemeIds.indexOf(item.Id) == -1) { - currentOwnerId = null; +function loadThemeMedia(item) { + if (item.CollectionType) { + stopIfPlaying(); + return; + } + + if (excludeTypes.indexOf(item.Type) !== -1) { + stopIfPlaying(); + return; + } + + const apiClient = 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; + + if (ownerId !== currentOwnerId) { + const items = themeMediaResult.ThemeVideosResult.Items.length ? themeMediaResult.ThemeVideosResult.Items : themeMediaResult.ThemeSongsResult.Items; + + playThemeMedia(items, ownerId); } }); +} + +document.addEventListener('viewshow', function (e) { + const state = e.detail.state || {}; + const item = state.item; + + if (item && item.ServerId) { + loadThemeMedia(item); + return; + } + + const viewOptions = e.detail.options || {}; + + if (viewOptions.supportsThemeMedia) { + // Do nothing here, allow it to keep playing + } else { + playThemeMedia([], null); + } +}, true); + +Events.on(playbackManager, 'playbackstart', function (e, player) { + const item = playbackManager.currentItem(player); + // User played something manually + if (currentThemeIds.indexOf(item.Id) == -1) { + currentOwnerId = null; + } }); + From 5dbf93d42d41aa0fff2f7a4ed16370fff6eecb61 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 6 Aug 2020 11:41:58 +0100 Subject: [PATCH 3/5] Migration of viewSettings to ES6 module --- package.json | 1 + src/components/viewSettings/viewSettings.js | 121 +++++++++++--------- 2 files changed, 66 insertions(+), 56 deletions(-) diff --git a/package.json b/package.json index aceef6b67e..7e0e76c6d7 100644 --- a/package.json +++ b/package.json @@ -171,6 +171,7 @@ "src/components/toast/toast.js", "src/components/upnextdialog/upnextdialog.js", "src/components/viewContainer.js", + "src/components/viewSettings/viewSettings.js", "src/controllers/session/addServer/index.js", "src/controllers/session/forgotPassword/index.js", "src/controllers/session/redeemPassword/index.js", diff --git a/src/components/viewSettings/viewSettings.js b/src/components/viewSettings/viewSettings.js index 67abc25a9c..fd5b5c3f9e 100644 --- a/src/components/viewSettings/viewSettings.js +++ b/src/components/viewSettings/viewSettings.js @@ -1,57 +1,66 @@ -define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) { - 'use strict'; +import dialogHelper from 'dialogHelper'; +import layoutManager from 'layoutManager'; +import globalize from 'globalize'; +import * as userSettings from 'userSettings'; +import 'emby-checkbox'; +import 'emby-input'; +import 'paper-icon-button-light'; +import 'emby-select'; +import 'material-icons'; +import 'css!./../formdialog'; +import 'emby-button'; +import 'flexStyles'; - function onSubmit(e) { - e.preventDefault(); - return false; +function onSubmit(e) { + e.preventDefault(); + return false; +} + +function initEditor(context, settings) { + context.querySelector('form').addEventListener('submit', onSubmit); + + const elems = context.querySelectorAll('.viewSetting-checkboxContainer'); + + for (const elem of elems) { + elem.querySelector('input').checked = settings[elem.getAttribute('data-settingname')] || false; } - function initEditor(context, settings) { - context.querySelector('form').addEventListener('submit', onSubmit); + context.querySelector('.selectImageType').value = settings.imageType || 'primary'; +} - var elems = context.querySelectorAll('.viewSetting-checkboxContainer'); - - for (var i = 0, length = elems.length; i < length; i++) { - elems[i].querySelector('input').checked = settings[elems[i].getAttribute('data-settingname')] || false; - } - - context.querySelector('.selectImageType').value = settings.imageType || 'primary'; +function saveValues(context, settings, settingsKey) { + const elems = context.querySelectorAll('.viewSetting-checkboxContainer'); + for (const elem of elems) { + userSettings.set(settingsKey + '-' + elem.getAttribute('data-settingname'), elem.querySelector('input').checked); } - function saveValues(context, settings, settingsKey) { - var elems = context.querySelectorAll('.viewSetting-checkboxContainer'); - for (var i = 0, length = elems.length; i < length; i++) { - userSettings.set(settingsKey + '-' + elems[i].getAttribute('data-settingname'), elems[i].querySelector('input').checked); - } + userSettings.set(settingsKey + '-imageType', context.querySelector('.selectImageType').value); +} - userSettings.set(settingsKey + '-imageType', context.querySelector('.selectImageType').value); +function centerFocus(elem, horiz, on) { + import('scrollHelper').then(({default: scrollHelper}) => { + const fn = on ? 'on' : 'off'; + scrollHelper.centerFocus[fn](elem, horiz); + }); +} + +function showIfAllowed(context, selector, visible) { + const elem = context.querySelector(selector); + + if (visible && !elem.classList.contains('hiddenFromViewSettings')) { + elem.classList.remove('hide'); + } else { + elem.classList.add('hide'); } +} - function centerFocus(elem, horiz, on) { - require(['scrollHelper'], function (scrollHelper) { - var fn = on ? 'on' : 'off'; - scrollHelper.centerFocus[fn](elem, horiz); - }); +class ViewSettings { + constructor() { } - - function showIfAllowed(context, selector, visible) { - var elem = context.querySelector(selector); - - if (visible && !elem.classList.contains('hiddenFromViewSettings')) { - elem.classList.remove('hide'); - } else { - elem.classList.add('hide'); - } - } - - function ViewSettings() { - - } - - ViewSettings.prototype.show = function (options) { + show(options) { return new Promise(function (resolve, reject) { - require(['text!./viewSettings.template.html'], function (template) { - var dialogOptions = { + import('text!./viewSettings.template.html').then(({default: template}) => { + const dialogOptions = { removeOnClose: true, scrollY: false }; @@ -62,11 +71,11 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne dialogOptions.size = 'small'; } - var dlg = dialogHelper.createDialog(dialogOptions); + const dlg = dialogHelper.createDialog(dialogOptions); dlg.classList.add('formDialog'); - var html = ''; + let html = ''; html += '
'; html += ''; @@ -78,14 +87,14 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne dlg.innerHTML = globalize.translateHtml(html, 'core'); - var settingElements = dlg.querySelectorAll('.viewSetting'); - for (var i = 0, length = settingElements.length; i < length; i++) { - if (options.visibleSettings.indexOf(settingElements[i].getAttribute('data-settingname')) === -1) { - settingElements[i].classList.add('hide'); - settingElements[i].classList.add('hiddenFromViewSettings'); + const settingElements = dlg.querySelectorAll('.viewSetting'); + for (const settingElement of settingElements) { + if (options.visibleSettings.indexOf(settingElement.getAttribute('data-settingname')) === -1) { + settingElement.classList.add('hide'); + settingElement.classList.add('hiddenFromViewSettings'); } else { - settingElements[i].classList.remove('hide'); - settingElements[i].classList.remove('hiddenFromViewSettings'); + settingElement.classList.remove('hide'); + settingElement.classList.remove('hiddenFromViewSettings'); } } @@ -104,7 +113,7 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne centerFocus(dlg.querySelector('.formDialogContent'), false, true); } - var submitted; + let submitted; dlg.querySelector('.selectImageType').dispatchEvent(new CustomEvent('change', {})); @@ -127,7 +136,7 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne }); }); }); - }; + } +} - return ViewSettings; -}); +export default ViewSettings; From 492a59db82b73fafdd2dbdbae50be039ee2ae0e9 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 11 Aug 2020 21:22:17 +0100 Subject: [PATCH 4/5] Update src/components/themeMediaPlayer.js Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com> --- src/components/themeMediaPlayer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/themeMediaPlayer.js b/src/components/themeMediaPlayer.js index 4ee9e0c910..8225156bf0 100644 --- a/src/components/themeMediaPlayer.js +++ b/src/components/themeMediaPlayer.js @@ -1,5 +1,5 @@ import playbackManager from 'playbackManager'; -import userSettings from 'userSettings'; +import * as userSettings from 'userSettings'; import connectionManager from 'connectionManager'; let currentOwnerId; @@ -99,4 +99,3 @@ Events.on(playbackManager, 'playbackstart', function (e, player) { currentOwnerId = null; } }); - From 67f32becd4cada1dfb34f681a1a6b60f8e0896c6 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 12 Aug 2020 09:13:46 +0100 Subject: [PATCH 5/5] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e67944ffcf..7bce50c2e1 100644 --- a/package.json +++ b/package.json @@ -223,8 +223,8 @@ "src/controllers/dashboard/metadataImages.js", "src/controllers/dashboard/metadatanfo.js", "src/controllers/dashboard/networking.js", - "src/controllers/dashboard/notifications/notification.js", - "src/controllers/dashboard/notifications/notifications.js", + "src/controllers/dashboard/notifications/notification/index.js", + "src/controllers/dashboard/notifications/notifications/index.js", "src/controllers/dashboard/playback.js", "src/controllers/dashboard/plugins/add/index.js", "src/controllers/dashboard/plugins/installed/index.js",