cleanup duplicate userSettings from libraryBrowser
This commit is contained in:
parent
d8c25b4594
commit
1825b821af
15 changed files with 147 additions and 196 deletions
|
@ -12,8 +12,8 @@ import Events from '../../utils/events.ts';
|
|||
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||
|
||||
export default function (view, params, tabContent) {
|
||||
function getPageData(context) {
|
||||
const key = getSavedQueryKey(context);
|
||||
function getPageData() {
|
||||
const key = getSavedQueryKey();
|
||||
let pageData = data[key];
|
||||
|
||||
if (!pageData) {
|
||||
|
@ -35,28 +35,24 @@ export default function (view, params, tabContent) {
|
|||
}
|
||||
|
||||
pageData.query.ParentId = params.topParentId;
|
||||
libraryBrowser.loadSavedQueryValues(key, pageData.query);
|
||||
userSettings.loadQuerySettings(key, pageData.query);
|
||||
}
|
||||
|
||||
return pageData;
|
||||
}
|
||||
|
||||
function getQuery(context) {
|
||||
return getPageData(context).query;
|
||||
function getQuery() {
|
||||
return getPageData().query;
|
||||
}
|
||||
|
||||
function getSavedQueryKey(context) {
|
||||
if (!context.savedQueryKey) {
|
||||
context.savedQueryKey = libraryBrowser.getSavedQueryKey('songs');
|
||||
}
|
||||
|
||||
return context.savedQueryKey;
|
||||
function getSavedQueryKey() {
|
||||
return `${params.topParentId}-songs`;
|
||||
}
|
||||
|
||||
function reloadItems(page) {
|
||||
loading.show();
|
||||
isLoading = true;
|
||||
const query = getQuery(page);
|
||||
const query = getQuery();
|
||||
ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function (result) {
|
||||
function onNextPageClick() {
|
||||
if (isLoading) {
|
||||
|
@ -117,7 +113,7 @@ export default function (view, params, tabContent) {
|
|||
const itemsContainer = tabContent.querySelector('.itemsContainer');
|
||||
itemsContainer.innerHTML = html;
|
||||
imageLoader.lazyChildren(itemsContainer);
|
||||
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
|
||||
userSettings.saveQuerySettings(getSavedQueryKey(), query);
|
||||
|
||||
tabContent.querySelector('.btnShuffle').classList.toggle('hide', result.TotalRecordCount < 1);
|
||||
|
||||
|
@ -137,13 +133,13 @@ export default function (view, params, tabContent) {
|
|||
self.showFilterMenu = function () {
|
||||
import('../../components/filterdialog/filterdialog').then(({ default: FilterDialog }) => {
|
||||
const filterDialog = new FilterDialog({
|
||||
query: getQuery(tabContent),
|
||||
query: getQuery(),
|
||||
mode: 'songs',
|
||||
serverId: ApiClient.serverId()
|
||||
});
|
||||
Events.on(filterDialog, 'filterchange', function () {
|
||||
getQuery(tabContent).StartIndex = 0;
|
||||
reloadItems(tabContent);
|
||||
getQuery().StartIndex = 0;
|
||||
reloadItems();
|
||||
});
|
||||
filterDialog.show();
|
||||
});
|
||||
|
@ -156,7 +152,7 @@ export default function (view, params, tabContent) {
|
|||
}
|
||||
|
||||
self.getCurrentViewStyle = function () {
|
||||
return getPageData(tabContent).view;
|
||||
return getPageData().view;
|
||||
};
|
||||
|
||||
function initPage(tabElement) {
|
||||
|
@ -197,10 +193,10 @@ export default function (view, params, tabContent) {
|
|||
id: 'Random,SortName'
|
||||
}],
|
||||
callback: function () {
|
||||
getQuery(tabElement).StartIndex = 0;
|
||||
reloadItems(tabElement);
|
||||
getQuery().StartIndex = 0;
|
||||
reloadItems();
|
||||
},
|
||||
query: getQuery(tabElement),
|
||||
query: getQuery(),
|
||||
button: e.target
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue