Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sort options to playback requests #4786

Merged
merged 16 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/components/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -184,11 +176,11 @@ function executeAction(card, target, action) {
id = card.getAttribute('data-id');
}

const itemsContainer = dom.parentWithClass(card, 'itemsContainer');
const item = getItemInfoFromCard(card);

const parentId = itemsContainer.getAttribute('data-parentid');
const itemsContainer = dom.parentWithClass(card, 'itemsContainer');

const item = getItemInfoFromCard(card);
const sortParentId = 'items-' + (item.IsFolder ? item.Id : itemsContainer.getAttribute('data-parentid')) + '-Folder';
dmitrylyzo marked this conversation as resolved.
Show resolved Hide resolved

const serverId = item.ServerId;
const type = item.Type;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions src/controllers/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,10 +962,7 @@ class ItemsView {

getSortValues() {
const basekey = this.getSettingsKey();
return {
sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
dmitrylyzo marked this conversation as resolved.
Show resolved Hide resolved
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
};
return userSettings.getSortValues(basekey);
}

getDefaultSortBy() {
Expand Down
13 changes: 13 additions & 0 deletions src/scripts/settings/userSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,18 @@ export class UserSettings {
getFilter(key) {
return this.get(key, true);
}

/**
* Gets the current sort values
* @param {string} key - Filter key.
v0idMrK marked this conversation as resolved.
Show resolved Hide resolved
* @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;
Expand Down Expand Up @@ -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);