mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Added getSortOptions to userSettings.js and cleaned up the shortcuts.js and list.js to use the above method
This commit is contained in:
parent
f922742d86
commit
580ad5f1a8
3 changed files with 18 additions and 16 deletions
|
@ -166,14 +166,6 @@ function showPlayMenu(card, target) {
|
|||
});
|
||||
}
|
||||
|
||||
function getSortValues(parentId) {
|
||||
const basekey = 'items-' + parentId + '-Folder';
|
||||
return {
|
||||
sortBy: userSettings.getFilter(basekey + '-sortby'),
|
||||
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
|
||||
};
|
||||
}
|
||||
|
||||
function executeAction(card, target, action) {
|
||||
target = target || card;
|
||||
|
||||
|
@ -184,11 +176,11 @@ function executeAction(card, target, action) {
|
|||
id = card.getAttribute('data-id');
|
||||
}
|
||||
|
||||
const item = getItemInfoFromCard(card);
|
||||
|
||||
const itemsContainer = dom.parentWithClass(card, 'itemsContainer');
|
||||
|
||||
const parentId = itemsContainer.getAttribute('data-parentid');
|
||||
|
||||
const item = getItemInfoFromCard(card);
|
||||
const sortParentId = 'items-' + (item.IsFolder ? item.Id : itemsContainer.getAttribute('data-parentid')) + '-Folder';
|
||||
|
||||
const serverId = item.ServerId;
|
||||
const type = item.Type;
|
||||
|
@ -219,7 +211,7 @@ function executeAction(card, target, action) {
|
|||
ids: [playableItemId],
|
||||
startPositionTicks: startPositionTicks,
|
||||
serverId: serverId,
|
||||
sortOptions: getSortValues(parentId)
|
||||
sortOptions: userSettings.getSortValues(sortParentId)
|
||||
});
|
||||
} else {
|
||||
console.warn('Unable to play item', item);
|
||||
|
|
|
@ -962,10 +962,7 @@ class ItemsView {
|
|||
|
||||
getSortValues() {
|
||||
const basekey = this.getSettingsKey();
|
||||
return {
|
||||
sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
|
||||
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
|
||||
};
|
||||
return userSettings.getSortValues(basekey);
|
||||
}
|
||||
|
||||
getDefaultSortBy() {
|
||||
|
|
|
@ -622,6 +622,18 @@ export class UserSettings {
|
|||
getFilter(key) {
|
||||
return this.get(key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current sort values
|
||||
* @param {string} key - Filter key.
|
||||
* @return {Object} sortOptions object
|
||||
*/
|
||||
getSortValues(key) {
|
||||
return {
|
||||
sortBy: this.getFilter(key + '-sortby'),
|
||||
sortOrder: this.getFilter(key + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export const currentSettings = new UserSettings;
|
||||
|
@ -672,3 +684,4 @@ export const customCss = currentSettings.customCss.bind(currentSettings);
|
|||
export const disableCustomCss = currentSettings.disableCustomCss.bind(currentSettings);
|
||||
export const getSavedView = currentSettings.getSavedView.bind(currentSettings);
|
||||
export const saveViewSetting = currentSettings.saveViewSetting.bind(currentSettings);
|
||||
export const getSortValues = currentSettings.getSortValues.bind(currentSettings);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue