Fix code smells

This commit is contained in:
Bill Thornton 2020-11-25 10:28:41 -05:00
parent 1a0789f7b9
commit 2d97a56f51
5 changed files with 32 additions and 40 deletions

View File

@ -13,7 +13,7 @@ import template from './dialog.template.html';
/* eslint-disable indent */ /* eslint-disable indent */
function showDialog(options, template) { function showDialog(options) {
const dialogOptions = { const dialogOptions = {
removeOnClose: true, removeOnClose: true,
scrollY: false scrollY: false
@ -129,9 +129,7 @@ import template from './dialog.template.html';
options = text; options = text;
} }
return new Promise((resolve, reject) => { return showDialog(options);
showDialog(options, template).then(resolve, reject);
});
} }
/* eslint-enable indent */ /* eslint-enable indent */

View File

@ -1092,17 +1092,17 @@ function Guide(options) {
} }
} }
const context = options.element; const guideContext = options.element;
context.classList.add('tvguide'); guideContext.classList.add('tvguide');
context.innerHTML = globalize.translateHtml(template, 'core'); guideContext.innerHTML = globalize.translateHtml(template, 'core');
const programGrid = context.querySelector('.programGrid'); const programGrid = guideContext.querySelector('.programGrid');
const timeslotHeaders = context.querySelector('.timeslotHeaders'); const timeslotHeaders = guideContext.querySelector('.timeslotHeaders');
if (layoutManager.tv) { if (layoutManager.tv) {
dom.addEventListener(context.querySelector('.guideVerticalScroller'), 'focus', onScrollerFocus, { dom.addEventListener(guideContext.querySelector('.guideVerticalScroller'), 'focus', onScrollerFocus, {
capture: true, capture: true,
passive: true passive: true
}); });
@ -1111,43 +1111,43 @@ function Guide(options) {
} }
if (browser.iOS || browser.osx) { if (browser.iOS || browser.osx) {
context.querySelector('.channelsContainer').classList.add('noRubberBanding'); guideContext.querySelector('.channelsContainer').classList.add('noRubberBanding');
programGrid.classList.add('noRubberBanding'); programGrid.classList.add('noRubberBanding');
} }
dom.addEventListener(programGrid, 'scroll', function (e) { dom.addEventListener(programGrid, 'scroll', function (e) {
onProgramGridScroll(context, this, timeslotHeaders); onProgramGridScroll(guideContext, this, timeslotHeaders);
}, { }, {
passive: true passive: true
}); });
dom.addEventListener(timeslotHeaders, 'scroll', function () { dom.addEventListener(timeslotHeaders, 'scroll', function () {
onTimeslotHeadersScroll(context, this); onTimeslotHeadersScroll(guideContext, this);
}, { }, {
passive: true passive: true
}); });
programGrid.addEventListener('click', onProgramGridClick); programGrid.addEventListener('click', onProgramGridClick);
context.querySelector('.btnNextPage').addEventListener('click', function () { guideContext.querySelector('.btnNextPage').addEventListener('click', function () {
currentStartIndex += currentChannelLimit; currentStartIndex += currentChannelLimit;
reloadPage(context); reloadPage(guideContext);
restartAutoRefresh(); restartAutoRefresh();
}); });
context.querySelector('.btnPreviousPage').addEventListener('click', function () { guideContext.querySelector('.btnPreviousPage').addEventListener('click', function () {
currentStartIndex = Math.max(currentStartIndex - currentChannelLimit, 0); currentStartIndex = Math.max(currentStartIndex - currentChannelLimit, 0);
reloadPage(context); reloadPage(guideContext);
restartAutoRefresh(); restartAutoRefresh();
}); });
context.querySelector('.btnGuideViewSettings').addEventListener('click', function () { guideContext.querySelector('.btnGuideViewSettings').addEventListener('click', function () {
showViewSettings(self); showViewSettings(self);
restartAutoRefresh(); restartAutoRefresh();
}); });
context.querySelector('.guideDateTabs').addEventListener('tabchange', function (e) { guideContext.querySelector('.guideDateTabs').addEventListener('tabchange', function (e) {
const allTabButtons = e.target.querySelectorAll('.guide-date-tab-button'); const allTabButtons = e.target.querySelectorAll('.guide-date-tab-button');
const tabButton = allTabButtons[parseInt(e.detail.selectedTabIndex)]; const tabButton = allTabButtons[parseInt(e.detail.selectedTabIndex)];
@ -1176,12 +1176,12 @@ function Guide(options) {
let startTimeOfDayMs = (date.getHours() * 60 * 60 * 1000); let startTimeOfDayMs = (date.getHours() * 60 * 60 * 1000);
startTimeOfDayMs += (date.getMinutes() * 60 * 1000); startTimeOfDayMs += (date.getMinutes() * 60 * 1000);
changeDate(context, date, scrollToTimeMs, scrollToTimeMs, startTimeOfDayMs, false); changeDate(guideContext, date, scrollToTimeMs, scrollToTimeMs, startTimeOfDayMs, false);
} }
}); });
setScrollEvents(context, true); setScrollEvents(guideContext, true);
itemShortcuts.on(context); itemShortcuts.on(guideContext);
Events.trigger(self, 'load'); Events.trigger(self, 'load');

View File

@ -163,7 +163,7 @@ import template from './itemMediaInfo.template.html';
return `<span class="mediaInfoLabel">${label}</span><span class="mediaInfoAttribute">${value}</span>`; return `<span class="mediaInfoLabel">${label}</span><span class="mediaInfoAttribute">${value}</span>`;
} }
function loadMediaInfo(itemId, serverId, template) { function loadMediaInfo(itemId, serverId) {
const apiClient = ServerConnections.getApiClient(serverId); const apiClient = ServerConnections.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(item => { return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(item => {
const dialogOptions = { const dialogOptions = {
@ -195,9 +195,7 @@ import template from './itemMediaInfo.template.html';
export function show(itemId, serverId) { export function show(itemId, serverId) {
loading.show(); loading.show();
return new Promise((resolve, reject) => { return loadMediaInfo(itemId, serverId);
loadMediaInfo(itemId, serverId, template).then(resolve, reject);
});
} }
/* eslint-enable indent */ /* eslint-enable indent */

View File

@ -28,7 +28,7 @@ export default (() => {
txtInput.value = options.value || ''; txtInput.value = options.value || '';
} }
function showDialog(options, template) { function showDialog(options) {
const dialogOptions = { const dialogOptions = {
removeOnClose: true, removeOnClose: true,
scrollY: false scrollY: false
@ -117,15 +117,13 @@ export default (() => {
}; };
} else { } else {
return options => { return options => {
return new Promise((resolve, reject) => { if (typeof options === 'string') {
if (typeof options === 'string') { options = {
options = { title: '',
title: '', text: options
text: options };
}; }
} return showDialog(options);
showDialog(options, template).then(resolve, reject);
});
}; };
} }
})(); })();

View File

@ -375,7 +375,7 @@ function onOpenUploadMenu(e) {
}); });
} }
function showEditorInternal(itemId, serverId, template) { function showEditorInternal(itemId, serverId) {
hasChanges = false; hasChanges = false;
const apiClient = ServerConnections.getApiClient(serverId); const apiClient = ServerConnections.getApiClient(serverId);
@ -454,9 +454,7 @@ function showEditorInternal(itemId, serverId, template) {
function showEditor(itemId, serverId) { function showEditor(itemId, serverId) {
loading.show(); loading.show();
return new Promise(function (resolve, reject) { return showEditorInternal(itemId, serverId);
showEditorInternal(itemId, serverId, template).then(resolve, reject);
});
} }
export default { export default {