From 84b9dc95f66237bfbeac58c9c7eff8114c4c8c27 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 5 Aug 2020 10:13:11 +0100 Subject: [PATCH 1/6] Migration of recording editor and fields to ES6 modules --- package.json | 2 + .../recordingcreator/recordingcreator.js | 2 +- .../recordingcreator/recordingeditor.js | 275 ++++++------ .../recordingcreator/recordingfields.js | 402 +++++++++--------- 4 files changed, 353 insertions(+), 328 deletions(-) diff --git a/package.json b/package.json index 8408217bf3..b38116cc5b 100644 --- a/package.json +++ b/package.json @@ -153,6 +153,8 @@ "src/components/playmenu.js", "src/components/prompt/prompt.js", "src/components/refreshdialog/refreshdialog.js", + "src/components/recordingcreator/recordingeditor.js", + "src/components/recordingcreator/recordingfields.js", "src/components/sanatizefilename.js", "src/components/scrollManager.js", "src/plugins/htmlVideoPlayer/plugin.js", diff --git a/src/components/recordingcreator/recordingcreator.js b/src/components/recordingcreator/recordingcreator.js index ca5c475829..511ba00fcd 100644 --- a/src/components/recordingcreator/recordingcreator.js +++ b/src/components/recordingcreator/recordingcreator.js @@ -168,7 +168,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c reload(dlg, itemId, serverId); - currentRecordingFields = new recordingFields({ + currentRecordingFields = new recordingFields.default({ parent: dlg.querySelector('.recordingFields'), programId: itemId, serverId: serverId diff --git a/src/components/recordingcreator/recordingeditor.js b/src/components/recordingcreator/recordingeditor.js index 2086129a9e..047d491c02 100644 --- a/src/components/recordingcreator/recordingeditor.js +++ b/src/components/recordingcreator/recordingeditor.js @@ -1,147 +1,160 @@ -define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'scrollStyles', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader) { - 'use strict'; +import dialogHelper from 'dialogHelper'; +import globalize from 'globalize'; +import layoutManager from 'layoutManager'; +import connectionManager from 'connectionManager'; +import require from 'require'; +import loading from 'loading'; +import scrollHelper from 'scrollHelper'; +import 'scrollStyles'; +import 'emby-button'; +import 'emby-collapse'; +import 'emby-input'; +import 'paper-icon-button-light'; +import 'css!./../formdialog'; +import 'css!./recordingcreator'; +import 'material-icons'; +import 'flexStyles'; - loading = loading.default || loading; +/*eslint prefer-const: "error"*/ - var currentDialog; - var recordingDeleted = false; - var currentItemId; - var currentServerId; - var currentResolve; +let currentDialog; +let recordingDeleted = false; +let currentItemId; +let currentServerId; +let currentResolve; - function deleteTimer(apiClient, timerId) { - return new Promise(function (resolve, reject) { - require(['recordingHelper'], function (recordingHelper) { - recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject); - }); +function deleteTimer(apiClient, timerId) { + return new Promise(function (resolve, reject) { + require(['recordingHelper'], function (recordingHelper) { + recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject); }); - } + }); +} - function renderTimer(context, item, apiClient) { - context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60; - context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60; +function renderTimer(context, item, apiClient) { + context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60; + context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60; + loading.hide(); +} + +function closeDialog(isDeleted) { + recordingDeleted = isDeleted; + + dialogHelper.close(currentDialog); +} + +function onSubmit(e) { + const form = this; + + const apiClient = connectionManager.getApiClient(currentServerId); + + apiClient.getLiveTvTimer(currentItemId).then(function (item) { + item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60; + item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60; + apiClient.updateLiveTvTimer(item).then(currentResolve); + }); + + e.preventDefault(); + + // Disable default form submission + return false; +} + +function init(context) { + context.querySelector('.btnCancel').addEventListener('click', function () { + closeDialog(false); + }); + + context.querySelector('.btnCancelRecording').addEventListener('click', function () { + const apiClient = connectionManager.getApiClient(currentServerId); + deleteTimer(apiClient, currentItemId).then(function () { + closeDialog(true); + }); + }); + + context.querySelector('form').addEventListener('submit', onSubmit); +} + +function reload(context, id) { + loading.show(); + currentItemId = id; + + const apiClient = connectionManager.getApiClient(currentServerId); + apiClient.getLiveTvTimer(id).then(function (result) { + renderTimer(context, result, apiClient); loading.hide(); - } + }); +} - function closeDialog(isDeleted) { - recordingDeleted = isDeleted; - - dialogHelper.close(currentDialog); - } - - function onSubmit(e) { - var form = this; - - var apiClient = connectionManager.getApiClient(currentServerId); - - apiClient.getLiveTvTimer(currentItemId).then(function (item) { - item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60; - item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60; - apiClient.updateLiveTvTimer(item).then(currentResolve); - }); - - e.preventDefault(); - - // Disable default form submission - return false; - } - - function init(context) { - context.querySelector('.btnCancel').addEventListener('click', function () { - closeDialog(false); - }); - - context.querySelector('.btnCancelRecording').addEventListener('click', function () { - var apiClient = connectionManager.getApiClient(currentServerId); - deleteTimer(apiClient, currentItemId).then(function () { - closeDialog(true); - }); - }); - - context.querySelector('form').addEventListener('submit', onSubmit); - } - - function reload(context, id) { +function showEditor(itemId, serverId, options) { + return new Promise(function (resolve, reject) { + recordingDeleted = false; + currentServerId = serverId; loading.show(); - currentItemId = id; + options = options || {}; + currentResolve = resolve; - var apiClient = connectionManager.getApiClient(currentServerId); - apiClient.getLiveTvTimer(id).then(function (result) { - renderTimer(context, result, apiClient); - loading.hide(); - }); - } + require(['text!./recordingeditor.template.html'], function (template) { + const dialogOptions = { + removeOnClose: true, + scrollY: false + }; - function showEditor(itemId, serverId, options) { - return new Promise(function (resolve, reject) { - recordingDeleted = false; - currentServerId = serverId; - loading.show(); - options = options || {}; - currentResolve = resolve; + if (layoutManager.tv) { + dialogOptions.size = 'fullscreen'; + } - require(['text!./recordingeditor.template.html'], function (template) { - var dialogOptions = { - removeOnClose: true, - scrollY: false - }; + const dlg = dialogHelper.createDialog(dialogOptions); - if (layoutManager.tv) { - dialogOptions.size = 'fullscreen'; + dlg.classList.add('formDialog'); + dlg.classList.add('recordingDialog'); + + if (!layoutManager.tv) { + dlg.style['min-width'] = '20%'; + dlg.classList.add('dialog-fullscreen-lowres'); + } + + let html = ''; + + html += globalize.translateHtml(template, 'core'); + + dlg.innerHTML = html; + + if (options.enableCancel === false) { + dlg.querySelector('.formDialogFooter').classList.add('hide'); + } + + currentDialog = dlg; + + dlg.addEventListener('closing', function () { + if (!recordingDeleted) { + dlg.querySelector('.btnSubmit').click(); } - - var dlg = dialogHelper.createDialog(dialogOptions); - - dlg.classList.add('formDialog'); - dlg.classList.add('recordingDialog'); - - if (!layoutManager.tv) { - dlg.style['min-width'] = '20%'; - dlg.classList.add('dialog-fullscreen-lowres'); - } - - var html = ''; - - html += globalize.translateHtml(template, 'core'); - - dlg.innerHTML = html; - - if (options.enableCancel === false) { - dlg.querySelector('.formDialogFooter').classList.add('hide'); - } - - currentDialog = dlg; - - dlg.addEventListener('closing', function () { - if (!recordingDeleted) { - dlg.querySelector('.btnSubmit').click(); - } - }); - - dlg.addEventListener('close', function () { - if (recordingDeleted) { - resolve({ - updated: true, - deleted: true - }); - } - }); - - if (layoutManager.tv) { - scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false); - } - - init(dlg); - - reload(dlg, itemId); - - dialogHelper.open(dlg); }); - }); - } - return { - show: showEditor - }; -}); + dlg.addEventListener('close', function () { + if (recordingDeleted) { + resolve({ + updated: true, + deleted: true + }); + } + }); + + if (layoutManager.tv) { + scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false); + } + + init(dlg); + + reload(dlg, itemId); + + dialogHelper.open(dlg); + }); + }); +} + +export default { + show: showEditor +}; diff --git a/src/components/recordingcreator/recordingfields.js b/src/components/recordingcreator/recordingfields.js index e3739f1cfe..d9d7c0098c 100644 --- a/src/components/recordingcreator/recordingfields.js +++ b/src/components/recordingcreator/recordingfields.js @@ -1,221 +1,126 @@ -define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) { - 'use strict'; +import globalize from 'globalize'; +import connectionManager from 'connectionManager'; +import serverNotifications from 'serverNotifications'; +import loading from 'loading'; +import dom from 'dom'; +import recordingHelper from 'recordingHelper'; +import events from 'events'; +import 'paper-icon-button-light'; +import 'emby-button'; +import 'css!./recordingfields'; +import 'flexStyles'; - loading = loading.default || loading; +/*eslint prefer-const: "error"*/ - function loadData(parent, program, apiClient) { - if (program.IsSeries) { - parent.querySelector('.recordSeriesContainer').classList.remove('hide'); +function loadData(parent, program, apiClient) { + if (program.IsSeries) { + parent.querySelector('.recordSeriesContainer').classList.remove('hide'); + } else { + parent.querySelector('.recordSeriesContainer').classList.add('hide'); + } + + if (program.SeriesTimerId) { + parent.querySelector('.btnManageSeriesRecording').classList.remove('hide'); + parent.querySelector('.seriesRecordingButton .recordingIcon').classList.add('recordingIcon-active'); + parent.querySelector('.seriesRecordingButton .buttonText').innerHTML = globalize.translate('CancelSeries'); + } else { + parent.querySelector('.btnManageSeriesRecording').classList.add('hide'); + parent.querySelector('.seriesRecordingButton .recordingIcon').classList.remove('recordingIcon-active'); + parent.querySelector('.seriesRecordingButton .buttonText').innerHTML = globalize.translate('RecordSeries'); + } + + if (program.TimerId && program.Status !== 'Cancelled') { + parent.querySelector('.btnManageRecording').classList.remove('hide'); + parent.querySelector('.singleRecordingButton .recordingIcon').classList.add('recordingIcon-active'); + if (program.Status === 'InProgress') { + parent.querySelector('.singleRecordingButton .buttonText').innerHTML = globalize.translate('StopRecording'); } else { - parent.querySelector('.recordSeriesContainer').classList.add('hide'); + parent.querySelector('.singleRecordingButton .buttonText').innerHTML = globalize.translate('DoNotRecord'); } + } else { + parent.querySelector('.btnManageRecording').classList.add('hide'); + parent.querySelector('.singleRecordingButton .recordingIcon').classList.remove('recordingIcon-active'); + parent.querySelector('.singleRecordingButton .buttonText').innerHTML = globalize.translate('Record'); + } +} - if (program.SeriesTimerId) { - parent.querySelector('.btnManageSeriesRecording').classList.remove('hide'); - parent.querySelector('.seriesRecordingButton .recordingIcon').classList.add('recordingIcon-active'); - parent.querySelector('.seriesRecordingButton .buttonText').innerHTML = globalize.translate('CancelSeries'); - } else { - parent.querySelector('.btnManageSeriesRecording').classList.add('hide'); - parent.querySelector('.seriesRecordingButton .recordingIcon').classList.remove('recordingIcon-active'); - parent.querySelector('.seriesRecordingButton .buttonText').innerHTML = globalize.translate('RecordSeries'); +function fetchData(instance) { + const options = instance.options; + const apiClient = connectionManager.getApiClient(options.serverId); + + options.parent.querySelector('.recordingFields').classList.remove('hide'); + return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) { + instance.TimerId = program.TimerId; + instance.Status = program.Status; + instance.SeriesTimerId = program.SeriesTimerId; + loadData(options.parent, program, apiClient); + }); +} + +function onTimerChangedExternally(e, apiClient, data) { + const options = this.options; + let refresh = false; + + if (data.Id) { + if (this.TimerId === data.Id) { + refresh = true; } - - if (program.TimerId && program.Status !== 'Cancelled') { - parent.querySelector('.btnManageRecording').classList.remove('hide'); - parent.querySelector('.singleRecordingButton .recordingIcon').classList.add('recordingIcon-active'); - if (program.Status === 'InProgress') { - parent.querySelector('.singleRecordingButton .buttonText').innerHTML = globalize.translate('StopRecording'); - } else { - parent.querySelector('.singleRecordingButton .buttonText').innerHTML = globalize.translate('DoNotRecord'); - } - } else { - parent.querySelector('.btnManageRecording').classList.add('hide'); - parent.querySelector('.singleRecordingButton .recordingIcon').classList.remove('recordingIcon-active'); - parent.querySelector('.singleRecordingButton .buttonText').innerHTML = globalize.translate('Record'); + } + if (data.ProgramId && options) { + if (options.programId === data.ProgramId) { + refresh = true; } } - function fetchData(instance) { - var options = instance.options; - var apiClient = connectionManager.getApiClient(options.serverId); - - options.parent.querySelector('.recordingFields').classList.remove('hide'); - return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) { - instance.TimerId = program.TimerId; - instance.Status = program.Status; - instance.SeriesTimerId = program.SeriesTimerId; - loadData(options.parent, program, apiClient); - }); + if (refresh) { + this.refresh(); } +} - function onTimerChangedExternally(e, apiClient, data) { - var options = this.options; - var refresh = false; +function onSeriesTimerChangedExternally(e, apiClient, data) { + const options = this.options; + let refresh = false; - if (data.Id) { - if (this.TimerId === data.Id) { - refresh = true; - } + if (data.Id) { + if (this.SeriesTimerId === data.Id) { + refresh = true; } - if (data.ProgramId && options) { - if (options.programId === data.ProgramId) { - refresh = true; - } - } - - if (refresh) { - this.refresh(); + } + if (data.ProgramId && options) { + if (options.programId === data.ProgramId) { + refresh = true; } } - function onSeriesTimerChangedExternally(e, apiClient, data) { - var options = this.options; - var refresh = false; - - if (data.Id) { - if (this.SeriesTimerId === data.Id) { - refresh = true; - } - } - if (data.ProgramId && options) { - if (options.programId === data.ProgramId) { - refresh = true; - } - } - - if (refresh) { - this.refresh(); - } + if (refresh) { + this.refresh(); } +} - function RecordingEditor(options) { +class RecordingEditor { + constructor(options) { this.options = options; this.embed(); - var timerChangedHandler = onTimerChangedExternally.bind(this); + const timerChangedHandler = onTimerChangedExternally.bind(this); this.timerChangedHandler = timerChangedHandler; events.on(serverNotifications, 'TimerCreated', timerChangedHandler); events.on(serverNotifications, 'TimerCancelled', timerChangedHandler); - var seriesTimerChangedHandler = onSeriesTimerChangedExternally.bind(this); + const seriesTimerChangedHandler = onSeriesTimerChangedExternally.bind(this); this.seriesTimerChangedHandler = seriesTimerChangedHandler; events.on(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler); events.on(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler); } - function onManageRecordingClick(e) { - var options = this.options; - if (!this.TimerId || this.Status === 'Cancelled') { - return; - } - - var self = this; - require(['recordingEditor'], function (recordingEditor) { - recordingEditor.show(self.TimerId, options.serverId, { - enableCancel: false - }).then(function () { - self.changed = true; - }); - }); - } - - function onManageSeriesRecordingClick(e) { - var options = this.options; - - if (!this.SeriesTimerId) { - return; - } - - var self = this; - - require(['seriesRecordingEditor'], function (seriesRecordingEditor) { - seriesRecordingEditor.show(self.SeriesTimerId, options.serverId, { - - enableCancel: false - - }).then(function () { - self.changed = true; - }); - }); - } - - function onRecordChange(e) { - this.changed = true; - - var self = this; - var options = this.options; - var apiClient = connectionManager.getApiClient(options.serverId); - - var button = dom.parentWithTag(e.target, 'BUTTON'); - var isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active'); - - var hasEnabledTimer = this.TimerId && this.Status !== 'Cancelled'; - - if (isChecked) { - if (!hasEnabledTimer) { - loading.show(); - recordingHelper.createRecording(apiClient, options.programId, false).then(function () { - events.trigger(self, 'recordingchanged'); - fetchData(self); - loading.hide(); - }); - } - } else { - if (hasEnabledTimer) { - loading.show(); - recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () { - events.trigger(self, 'recordingchanged'); - fetchData(self); - loading.hide(); - }); - } - } - } - - function sendToast(msg) { - require(['toast'], function (toast) { - toast(msg); - }); - } - - function onRecordSeriesChange(e) { - this.changed = true; - - var self = this; - var options = this.options; - var apiClient = connectionManager.getApiClient(options.serverId); - - var button = dom.parentWithTag(e.target, 'BUTTON'); - var isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active'); - - if (isChecked) { - options.parent.querySelector('.recordSeriesContainer').classList.remove('hide'); - if (!this.SeriesTimerId) { - var promise = this.TimerId ? - recordingHelper.changeRecordingToSeries(apiClient, this.TimerId, options.programId) : - recordingHelper.createRecording(apiClient, options.programId, true); - promise.then(function () { - fetchData(self); - }); - } - } else { - if (this.SeriesTimerId) { - apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () { - sendToast(globalize.translate('RecordingCancelled')); - fetchData(self); - }); - } - } - } - - RecordingEditor.prototype.embed = function () { - var self = this; + embed() { + const self = this; return new Promise(function (resolve, reject) { - require(['text!./recordingfields.template.html'], function (template) { - var options = self.options; - var context = options.parent; + import('text!./recordingfields.template.html').then(({default: template}) => { + const options = self.options; + const context = options.parent; context.innerHTML = globalize.translateHtml(template, 'core'); context.querySelector('.singleRecordingButton').addEventListener('click', onRecordChange.bind(self)); @@ -226,29 +131,134 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa fetchData(self).then(resolve); }); }); - }; + } - RecordingEditor.prototype.hasChanged = function () { + hasChanged() { return this.changed; - }; + } - RecordingEditor.prototype.refresh = function () { + refresh() { fetchData(this); - }; + } - RecordingEditor.prototype.destroy = function () { - var timerChangedHandler = this.timerChangedHandler; + destroy() { + const timerChangedHandler = this.timerChangedHandler; this.timerChangedHandler = null; events.off(serverNotifications, 'TimerCreated', timerChangedHandler); events.off(serverNotifications, 'TimerCancelled', timerChangedHandler); - var seriesTimerChangedHandler = this.seriesTimerChangedHandler; + const seriesTimerChangedHandler = this.seriesTimerChangedHandler; this.seriesTimerChangedHandler = null; events.off(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler); events.off(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler); - }; + } +} - return RecordingEditor; -}); +function onManageRecordingClick(e) { + const options = this.options; + if (!this.TimerId || this.Status === 'Cancelled') { + return; + } + + const self = this; + import('recordingEditor').then(({default: recordingEditor}) => { + recordingEditor.show(self.TimerId, options.serverId, { + enableCancel: false + }).then(function () { + self.changed = true; + }); + }); +} + +function onManageSeriesRecordingClick(e) { + const options = this.options; + + if (!this.SeriesTimerId) { + return; + } + + const self = this; + + import('seriesRecordingEditor').then(({default: seriesRecordingEditor}) => { + seriesRecordingEditor.show(self.SeriesTimerId, options.serverId, { + + enableCancel: false + + }).then(function () { + self.changed = true; + }); + }); +} + +function onRecordChange(e) { + this.changed = true; + + const self = this; + const options = this.options; + const apiClient = connectionManager.getApiClient(options.serverId); + + const button = dom.parentWithTag(e.target, 'BUTTON'); + const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active'); + + const hasEnabledTimer = this.TimerId && this.Status !== 'Cancelled'; + + if (isChecked) { + if (!hasEnabledTimer) { + loading.show(); + recordingHelper.createRecording(apiClient, options.programId, false).then(function () { + events.trigger(self, 'recordingchanged'); + fetchData(self); + loading.hide(); + }); + } + } else { + if (hasEnabledTimer) { + loading.show(); + recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () { + events.trigger(self, 'recordingchanged'); + fetchData(self); + loading.hide(); + }); + } + } +} + +function sendToast(msg) { + import('toast').then(({default: toast}) => { + toast(msg); + }); +} + +function onRecordSeriesChange(e) { + this.changed = true; + + const self = this; + const options = this.options; + const apiClient = connectionManager.getApiClient(options.serverId); + + const button = dom.parentWithTag(e.target, 'BUTTON'); + const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active'); + + if (isChecked) { + options.parent.querySelector('.recordSeriesContainer').classList.remove('hide'); + if (!this.SeriesTimerId) { + const promise = this.TimerId ? + recordingHelper.changeRecordingToSeries(apiClient, this.TimerId, options.programId) : + recordingHelper.createRecording(apiClient, options.programId, true); + promise.then(function () { + fetchData(self); + }); + } + } else { + if (this.SeriesTimerId) { + apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () { + sendToast(globalize.translate('RecordingCancelled')); + fetchData(self); + }); + } + } +} + +export default RecordingEditor; From abd6e02151a5c5d985172da69f053ad40ee49b53 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 7 Aug 2020 09:31:46 +0100 Subject: [PATCH 2/6] lint --- src/components/recordingcreator/recordingeditor.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/components/recordingcreator/recordingeditor.js b/src/components/recordingcreator/recordingeditor.js index c08feeeb83..6fe104b57f 100644 --- a/src/components/recordingcreator/recordingeditor.js +++ b/src/components/recordingcreator/recordingeditor.js @@ -15,22 +15,12 @@ import 'css!./recordingcreator'; import 'material-icons'; import 'flexStyles'; -/*eslint prefer-const: "error"*/ - let currentDialog; let recordingDeleted = false; let currentItemId; let currentServerId; let currentResolve; -function deleteTimer(apiClient, timerId) { - return new Promise(function (resolve, reject) { - require(['recordingHelper'], function (recordingHelper) { - recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject); - }); - }); -} - function renderTimer(context, item, apiClient) { context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60; context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60; @@ -67,8 +57,8 @@ function init(context) { context.querySelector('.btnCancelRecording').addEventListener('click', function () { const apiClient = connectionManager.getApiClient(currentServerId); - - (apiClient, currentItemId).then(function () { + + (apiClient, currentItemId).then(function () { closeDialog(true); }); }); From 0a9632b53170fb5502e905cb24f5ba454451330b Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 11 Aug 2020 18:34:28 +0100 Subject: [PATCH 3/6] Update recordingeditor.js --- src/components/recordingcreator/recordingeditor.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/recordingcreator/recordingeditor.js b/src/components/recordingcreator/recordingeditor.js index 6fe104b57f..5bd3d73c67 100644 --- a/src/components/recordingcreator/recordingeditor.js +++ b/src/components/recordingcreator/recordingeditor.js @@ -21,6 +21,12 @@ let currentItemId; let currentServerId; let currentResolve; +function deleteTimer(apiClient, timerId) { + return import('recordingHelper').then(({ default: recordingHelper }) => { + recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()); + }); +} + function renderTimer(context, item, apiClient) { context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60; context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60; @@ -58,7 +64,7 @@ function init(context) { context.querySelector('.btnCancelRecording').addEventListener('click', function () { const apiClient = connectionManager.getApiClient(currentServerId); - (apiClient, currentItemId).then(function () { + deleteTimer(apiClient, currentItemId).then(function () { closeDialog(true); }); }); From f3cdedacdf4d71318b597a487d18789d7de9c018 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 13 Aug 2020 09:19:32 +0100 Subject: [PATCH 4/6] Remove unneccessary .default --- .../recordingcreator/recordingcreator.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/recordingcreator/recordingcreator.js b/src/components/recordingcreator/recordingcreator.js index 412ec6e274..43a91b4992 100644 --- a/src/components/recordingcreator/recordingcreator.js +++ b/src/components/recordingcreator/recordingcreator.js @@ -118,7 +118,7 @@ function reload(context, programId, serverId, refreshRecordingStateOnly) { function executeCloseAction(action, programId, serverId) { if (action === 'play') { - import('playbackManager').then(({default: playbackManager}) => { + import('playbackManager').then(({ default: playbackManager }) => { const apiClient = connectionManager.getApiClient(serverId); apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) { @@ -138,7 +138,7 @@ function showEditor(itemId, serverId) { loading.show(); - import('text!./recordingcreator.template.html').then(({default: template}) => { + import('text!./recordingcreator.template.html').then(({ default: template }) => { const dialogOptions = { removeOnClose: true, scrollY: false @@ -184,13 +184,13 @@ function showEditor(itemId, serverId) { init(dlg); - currentRecordingFields = new recordingFields.default({ - parent: dlg.querySelector('.recordingFields'), - programId: itemId, - serverId: serverId - }); + currentRecordingFields = new recordingFields({ + parent: dlg.querySelector('.recordingFields'), + programId: itemId, + serverId: serverId + }); - events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged); + events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged); currentRecordingFields = new recordingFields({ parent: dlg.querySelector('.recordingFields'), From 5de2498f12cb4370dae14e3d418e3332dbda8835 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 13 Aug 2020 22:30:00 +0100 Subject: [PATCH 5/6] Update recordingcreator.js --- src/components/recordingcreator/recordingcreator.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/recordingcreator/recordingcreator.js b/src/components/recordingcreator/recordingcreator.js index 43a91b4992..9cb4e41d2e 100644 --- a/src/components/recordingcreator/recordingcreator.js +++ b/src/components/recordingcreator/recordingcreator.js @@ -184,13 +184,7 @@ function showEditor(itemId, serverId) { init(dlg); - currentRecordingFields = new recordingFields({ - parent: dlg.querySelector('.recordingFields'), - programId: itemId, - serverId: serverId - }); - - events.on(currentRecordingFields, 'recordingchanged', onRecordingChanged); + reload(dlg, itemId, serverId); currentRecordingFields = new recordingFields({ parent: dlg.querySelector('.recordingFields'), From b1c96575f229c62d4b069cc53304f7ad55c6a921 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 13 Aug 2020 22:31:31 +0100 Subject: [PATCH 6/6] remove missed require --- src/components/recordingcreator/recordingeditor.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/recordingcreator/recordingeditor.js b/src/components/recordingcreator/recordingeditor.js index 5bd3d73c67..096ea3b62c 100644 --- a/src/components/recordingcreator/recordingeditor.js +++ b/src/components/recordingcreator/recordingeditor.js @@ -2,7 +2,6 @@ import dialogHelper from 'dialogHelper'; import globalize from 'globalize'; import layoutManager from 'layoutManager'; import connectionManager from 'connectionManager'; -import require from 'require'; import loading from 'loading'; import scrollHelper from 'scrollHelper'; import 'scrollStyles'; @@ -91,7 +90,7 @@ function showEditor(itemId, serverId, options) { options = options || {}; currentResolve = resolve; - require(['text!./recordingeditor.template.html'], function (template) { + import('text!./recordingeditor.template.html').then(({default: template}) => { const dialogOptions = { removeOnClose: true, scrollY: false