Remove ailaising this in music

This commit is contained in:
Cameron 2020-08-02 12:16:14 +01:00
parent dbd6d2fb35
commit b5c1cbb5b3
6 changed files with 58 additions and 65 deletions

View File

@ -29,8 +29,6 @@ import 'emby-select';
/* eslint-disable indent */
loading = loading.default || loading;
function getPromise(apiClient, params) {
const id = params.id;

View File

@ -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 */

View File

@ -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 */

View File

@ -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);
};
}

View File

@ -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);
};
}

View File

@ -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();
};