From b5c1cbb5b39b59324666d1d2cdc5cd68d0a463e8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 2 Aug 2020 12:16:14 +0100 Subject: [PATCH] Remove ailaising this in music --- src/controllers/itemDetails/index.js | 2 -- src/controllers/music/musicalbums.js | 37 ++++++++++---------- src/controllers/music/musicartists.js | 41 +++++++++++------------ src/controllers/music/musicgenres.js | 23 ++++++------- src/controllers/music/musicplaylists.js | 7 ++-- src/controllers/music/musicrecommended.js | 13 ++++--- 6 files changed, 58 insertions(+), 65 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index c65ce39d84..df2855d69a 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -29,8 +29,6 @@ import 'emby-select'; /* eslint-disable indent */ - loading = loading.default || loading; - function getPromise(apiClient, params) { const id = params.id; diff --git a/src/controllers/music/musicalbums.js b/src/controllers/music/musicalbums.js index 7d03c91073..55c66aee66 100644 --- a/src/controllers/music/musicalbums.js +++ b/src/controllers/music/musicalbums.js @@ -69,8 +69,8 @@ import 'emby-itemscontainer'; return savedQueryKey; } - function onViewStyleChange() { - const viewStyle = self.getCurrentViewStyle(); + const onViewStyleChange = () => { + const viewStyle = this.getCurrentViewStyle(); const itemsContainer = tabContent.querySelector('.itemsContainer'); if (viewStyle == 'List') { @@ -84,11 +84,11 @@ import 'emby-itemscontainer'; itemsContainer.innerHTML = ''; } - function reloadItems(page) { + const reloadItems = (page) => { loading.show(); isLoading = true; const query = getQuery(); - ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function (result) { + ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => { function onNextPageClick() { if (isLoading) { return; @@ -124,7 +124,7 @@ import 'emby-itemscontainer'; sortButton: false, filterButton: false }); - const viewStyle = self.getCurrentViewStyle(); + const viewStyle = this.getCurrentViewStyle(); if (viewStyle == 'List') { html = listView.getListViewHtml({ items: result.Items, @@ -184,17 +184,16 @@ import 'emby-itemscontainer'; }); } - function updateFilterControls(tabContent) { + const updateFilterControls = (tabContent) => { const query = getQuery(); - self.alphaPicker.value(query.NameStartsWithOrGreater); + this.alphaPicker.value(query.NameStartsWithOrGreater); } let savedQueryKey; let pageData; - const self = this; let isLoading = false; - self.showFilterMenu = function () { + this.showFilterMenu = function () { import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => { const filterDialog = new filterDialogFactory({ query: getQuery(), @@ -209,11 +208,11 @@ import 'emby-itemscontainer'; }); }; - self.getCurrentViewStyle = function () { + this.getCurrentViewStyle = function () { return getPageData().view; }; - function initPage(tabContent) { + const initPage = (tabContent) => { const alphaPickerElement = tabContent.querySelector('.alphaPicker'); const itemsContainer = tabContent.querySelector('.itemsContainer'); @@ -224,7 +223,7 @@ import 'emby-itemscontainer'; query.StartIndex = 0; reloadItems(tabContent); }); - self.alphaPicker = new AlphaPicker({ + this.alphaPicker = new AlphaPicker({ element: alphaPickerElement, valueChangeEvent: 'click' }); @@ -233,10 +232,10 @@ import 'emby-itemscontainer'; alphaPickerElement.classList.add('alphaPicker-fixed-right'); itemsContainer.classList.add('padded-right-withalphapicker'); - tabContent.querySelector('.btnFilter').addEventListener('click', function () { - self.showFilterMenu(); + tabContent.querySelector('.btnFilter').addEventListener('click', () => { + this.showFilterMenu(); }); - tabContent.querySelector('.btnSort').addEventListener('click', function (e) { + tabContent.querySelector('.btnSort').addEventListener('click', (e) => { libraryBrowser.showSortMenu({ items: [{ name: globalize.translate('OptionNameSort'), @@ -269,8 +268,8 @@ import 'emby-itemscontainer'; }); }); const btnSelectView = tabContent.querySelector('.btnSelectView'); - btnSelectView.addEventListener('click', function (e) { - libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); + btnSelectView.addEventListener('click', (e) => { + libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); }); btnSelectView.addEventListener('layoutchange', function (e) { const viewStyle = e.detail.viewStyle; @@ -287,12 +286,12 @@ import 'emby-itemscontainer'; initPage(tabContent); onViewStyleChange(); - self.renderTab = function () { + this.renderTab = function () { reloadItems(tabContent); updateFilterControls(tabContent); }; - self.destroy = function () {}; + this.destroy = function () {}; } /* eslint-enable indent */ diff --git a/src/controllers/music/musicartists.js b/src/controllers/music/musicartists.js index 23e0bbd459..713f66a72a 100644 --- a/src/controllers/music/musicartists.js +++ b/src/controllers/music/musicartists.js @@ -45,16 +45,16 @@ import 'emby-itemscontainer'; return getPageData(context).query; } - function getSavedQueryKey(context) { + const getSavedQueryKey = (context) => { if (!context.savedQueryKey) { - context.savedQueryKey = libraryBrowser.getSavedQueryKey(self.mode); + context.savedQueryKey = libraryBrowser.getSavedQueryKey(this.mode); } return context.savedQueryKey; } - function onViewStyleChange() { - const viewStyle = self.getCurrentViewStyle(); + const onViewStyleChange = () => { + const viewStyle = this.getCurrentViewStyle(); const itemsContainer = tabContent.querySelector('.itemsContainer'); if (viewStyle == 'List') { @@ -68,14 +68,14 @@ import 'emby-itemscontainer'; itemsContainer.innerHTML = ''; } - function reloadItems(page) { + const reloadItems = (page) => { loading.show(); isLoading = true; const query = getQuery(page); - const promise = self.mode == 'albumartists' ? + const promise = this.mode == 'albumartists' ? ApiClient.getAlbumArtists(ApiClient.getCurrentUserId(), query) : ApiClient.getArtists(ApiClient.getCurrentUserId(), query); - promise.then(function (result) { + promise.then((result) => { function onNextPageClick() { if (isLoading) { return; @@ -111,7 +111,7 @@ import 'emby-itemscontainer'; sortButton: false, filterButton: false }); - const viewStyle = self.getCurrentViewStyle(); + const viewStyle = this.getCurrentViewStyle(); if (viewStyle == 'List') { html = listView.getListViewHtml({ items: result.Items, @@ -167,20 +167,19 @@ import 'emby-itemscontainer'; }); } - function updateFilterControls(tabContent) { + const updateFilterControls = (tabContent) => { const query = getQuery(tabContent); - self.alphaPicker.value(query.NameStartsWithOrGreater); + this.alphaPicker.value(query.NameStartsWithOrGreater); } - const self = this; const data = {}; let isLoading = false; - self.showFilterMenu = function () { + this.showFilterMenu = function () { import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => { const filterDialog = new filterDialogFactory({ query: getQuery(tabContent), - mode: self.mode, + mode: this.mode, serverId: ApiClient.serverId() }); events.on(filterDialog, 'filterchange', function () { @@ -191,11 +190,11 @@ import 'emby-itemscontainer'; }); }; - self.getCurrentViewStyle = function () { + this.getCurrentViewStyle = function () { return getPageData(tabContent).view; }; - function initPage(tabContent) { + const initPage = (tabContent) => { const alphaPickerElement = tabContent.querySelector('.alphaPicker'); const itemsContainer = tabContent.querySelector('.itemsContainer'); @@ -206,7 +205,7 @@ import 'emby-itemscontainer'; query.StartIndex = 0; reloadItems(tabContent); }); - self.alphaPicker = new AlphaPicker({ + this.alphaPicker = new AlphaPicker({ element: alphaPickerElement, valueChangeEvent: 'click' }); @@ -215,12 +214,12 @@ import 'emby-itemscontainer'; alphaPickerElement.classList.add('alphaPicker-fixed-right'); itemsContainer.classList.add('padded-right-withalphapicker'); - tabContent.querySelector('.btnFilter').addEventListener('click', function () { - self.showFilterMenu(); + tabContent.querySelector('.btnFilter').addEventListener('click', () => { + this.showFilterMenu(); }); const btnSelectView = tabContent.querySelector('.btnSelectView'); btnSelectView.addEventListener('click', function (e) { - libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); + libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle(), 'List,Poster,PosterCard'.split(',')); }); btnSelectView.addEventListener('layoutchange', function (e) { const viewStyle = e.detail.viewStyle; @@ -235,12 +234,12 @@ import 'emby-itemscontainer'; initPage(tabContent); onViewStyleChange(); - self.renderTab = function () { + this.renderTab = function () { reloadItems(tabContent); updateFilterControls(tabContent); }; - self.destroy = function () {}; + this.destroy = function () {}; } /* eslint-enable indent */ diff --git a/src/controllers/music/musicgenres.js b/src/controllers/music/musicgenres.js index 29e0d888e4..b018a270fb 100644 --- a/src/controllers/music/musicgenres.js +++ b/src/controllers/music/musicgenres.js @@ -42,11 +42,11 @@ import loading from 'loading'; return ApiClient.getGenres(ApiClient.getCurrentUserId(), query); } - function reloadItems(context, promise) { + const reloadItems = (context, promise) => { const query = getQuery(); - promise.then(function (result) { + promise.then((result) => { let html = ''; - const viewStyle = self.getCurrentViewStyle(); + const viewStyle = this.getCurrentViewStyle(); if (viewStyle == 'Thumb') { html = cardBuilder.getCardsHtml({ @@ -99,35 +99,34 @@ import loading from 'loading'; } function fullyReload() { - self.preRender(); - self.renderTab(); + this.preRender(); + this.renderTab(); } - const self = this; const data = {}; - self.getViewStyles = function () { + this.getViewStyles = function () { return 'Poster,PosterCard,Thumb,ThumbCard'.split(','); }; - self.getCurrentViewStyle = function () { + this.getCurrentViewStyle = function () { return getPageData().view; }; - self.setCurrentViewStyle = function (viewStyle) { + this.setCurrentViewStyle = function (viewStyle) { getPageData().view = viewStyle; libraryBrowser.saveViewSetting(getSavedQueryKey(), viewStyle); fullyReload(); }; - self.enableViewSelection = true; + this.enableViewSelection = true; let promise; - self.preRender = function () { + this.preRender = function () { promise = getPromise(); }; - self.renderTab = function () { + this.renderTab = function () { reloadItems(tabContent, promise); }; } diff --git a/src/controllers/music/musicplaylists.js b/src/controllers/music/musicplaylists.js index befeafcf4c..67e6a959eb 100644 --- a/src/controllers/music/musicplaylists.js +++ b/src/controllers/music/musicplaylists.js @@ -69,20 +69,19 @@ import loading from 'loading'; }); } - const self = this; const data = {}; - self.getCurrentViewStyle = function () { + this.getCurrentViewStyle = function () { return getPageData().view; }; let promise; - self.preRender = function () { + this.preRender = function () { promise = getPromise(); }; - self.renderTab = function () { + this.renderTab = function () { reloadItems(tabContent, promise); }; } diff --git a/src/controllers/music/musicrecommended.js b/src/controllers/music/musicrecommended.js index db7dac9547..df10d828bf 100644 --- a/src/controllers/music/musicrecommended.js +++ b/src/controllers/music/musicrecommended.js @@ -267,7 +267,7 @@ import 'flexStyles'; mainTabsManager.setTabs(view, currentTabIndex, getTabs, getTabContainers, onBeforeTabChange, onTabChange); } - function getTabController(page, index, callback) { + const getTabController = (page, index, callback) => { let depends; switch (index) { @@ -306,7 +306,7 @@ import 'flexStyles'; if (index == 0) { tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']"); - self.tabContent = tabContent; + this.tabContent = tabContent; } let controller = tabControllers[index]; @@ -315,7 +315,7 @@ import 'flexStyles'; tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']"); if (index === 0) { - controller = self; + controller = this; } else if (index === 7) { controller = new controllerFactory(view, tabContent, { collectionType: 'music', @@ -367,10 +367,9 @@ import 'flexStyles'; } } - var self = this; - var currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId)); + let currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId)); - self.initTab = function () { + this.initTab = function () { const tabContent = view.querySelector(".pageTabContent[data-index='0']"); const containers = tabContent.querySelectorAll('.itemsContainer'); @@ -379,7 +378,7 @@ import 'flexStyles'; } }; - self.renderTab = function () { + this.renderTab = function () { reload(); };