mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-16 10:28:18 -07:00
Merge pull request #4786 from v0idMrK/Sorting-Only-Thumbnail-Fix-5584
Add sort options to playback requests
This commit is contained in:
commit
edd94053ca
@ -66,6 +66,7 @@
|
|||||||
- [Fishbigger](https://github.com/fishbigger)
|
- [Fishbigger](https://github.com/fishbigger)
|
||||||
- [sleepycatcoding](https://github.com/sleepycatcoding)
|
- [sleepycatcoding](https://github.com/sleepycatcoding)
|
||||||
- [TheMelmacian](https://github.com/TheMelmacian)
|
- [TheMelmacian](https://github.com/TheMelmacian)
|
||||||
|
- [v0idMrK](https://github.com/v0idMrK)
|
||||||
- [tehciolo](https://github.com/tehciolo)
|
- [tehciolo](https://github.com/tehciolo)
|
||||||
- [scampower3](https://github.com/scampower3)
|
- [scampower3](https://github.com/scampower3)
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import itemHelper from './itemHelper';
|
|||||||
import { playbackManager } from './playback/playbackmanager';
|
import { playbackManager } from './playback/playbackmanager';
|
||||||
import ServerConnections from './ServerConnections';
|
import ServerConnections from './ServerConnections';
|
||||||
import toast from './toast/toast';
|
import toast from './toast/toast';
|
||||||
|
import * as userSettings from '../scripts/settings/userSettings';
|
||||||
|
|
||||||
export function getCommands(options) {
|
export function getCommands(options) {
|
||||||
const item = options.item;
|
const item = options.item;
|
||||||
@ -589,9 +590,16 @@ function play(item, resume, queue, queueNext) {
|
|||||||
serverId: item.ServerId
|
serverId: item.ServerId
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
const sortParentId = 'items-' + (item.IsFolder ? item.Id : item.ParentId) + '-Folder';
|
||||||
|
const sortValues = userSettings.getSortValuesLegacy(sortParentId);
|
||||||
|
|
||||||
playbackManager[method]({
|
playbackManager[method]({
|
||||||
items: [item],
|
items: [item],
|
||||||
startPositionTicks: startPosition
|
startPositionTicks: startPosition,
|
||||||
|
queryOptions: {
|
||||||
|
SortBy: sortValues.sortBy,
|
||||||
|
SortOrder: sortValues.sortOrder
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import { PluginType } from '../../types/plugin.ts';
|
|||||||
import { includesAny } from '../../utils/container.ts';
|
import { includesAny } from '../../utils/container.ts';
|
||||||
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
|
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
|
||||||
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
|
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
|
||||||
|
import merge from 'lodash-es/merge';
|
||||||
|
|
||||||
const UNLIMITED_ITEMS = -1;
|
const UNLIMITED_ITEMS = -1;
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ function createStreamInfoFromUrlItem(item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mergePlaybackQueries(obj1, obj2) {
|
function mergePlaybackQueries(obj1, obj2) {
|
||||||
const query = Object.assign(obj1, obj2);
|
const query = merge({}, obj1, obj2);
|
||||||
|
|
||||||
const filters = query.Filters ? query.Filters.split(',') : [];
|
const filters = query.Filters ? query.Filters.split(',') : [];
|
||||||
if (filters.indexOf('IsNotFolder') === -1) {
|
if (filters.indexOf('IsNotFolder') === -1) {
|
||||||
@ -1798,15 +1799,15 @@ class PlaybackManager {
|
|||||||
SortBy: options.shuffle ? 'Random' : null
|
SortBy: options.shuffle ? 'Random' : null
|
||||||
});
|
});
|
||||||
} else if (firstItem.Type === 'MusicArtist') {
|
} else if (firstItem.Type === 'MusicArtist') {
|
||||||
promise = getItemsForPlayback(serverId, {
|
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
||||||
ArtistIds: firstItem.Id,
|
ArtistIds: firstItem.Id,
|
||||||
Filters: 'IsNotFolder',
|
Filters: 'IsNotFolder',
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
SortBy: options.shuffle ? 'Random' : 'SortName',
|
SortBy: options.shuffle ? 'Random' : 'SortName',
|
||||||
MediaTypes: 'Audio'
|
MediaTypes: 'Audio'
|
||||||
});
|
}, queryOptions));
|
||||||
} else if (firstItem.MediaType === 'Photo') {
|
} else if (firstItem.MediaType === 'Photo') {
|
||||||
promise = getItemsForPlayback(serverId, {
|
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
||||||
ParentId: firstItem.ParentId,
|
ParentId: firstItem.ParentId,
|
||||||
Filters: 'IsNotFolder',
|
Filters: 'IsNotFolder',
|
||||||
// Setting this to true may cause some incorrect sorting
|
// Setting this to true may cause some incorrect sorting
|
||||||
@ -1814,7 +1815,7 @@ class PlaybackManager {
|
|||||||
SortBy: options.shuffle ? 'Random' : 'SortName',
|
SortBy: options.shuffle ? 'Random' : 'SortName',
|
||||||
MediaTypes: 'Photo,Video',
|
MediaTypes: 'Photo,Video',
|
||||||
Limit: UNLIMITED_ITEMS
|
Limit: UNLIMITED_ITEMS
|
||||||
}).then(function (result) {
|
}, queryOptions)).then(function (result) {
|
||||||
const playbackItems = result.Items;
|
const playbackItems = result.Items;
|
||||||
|
|
||||||
let index = playbackItems.map(function (i) {
|
let index = playbackItems.map(function (i) {
|
||||||
@ -1830,7 +1831,7 @@ class PlaybackManager {
|
|||||||
return Promise.resolve(result);
|
return Promise.resolve(result);
|
||||||
});
|
});
|
||||||
} else if (firstItem.Type === 'PhotoAlbum') {
|
} else if (firstItem.Type === 'PhotoAlbum') {
|
||||||
promise = getItemsForPlayback(serverId, {
|
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
||||||
ParentId: firstItem.Id,
|
ParentId: firstItem.Id,
|
||||||
Filters: 'IsNotFolder',
|
Filters: 'IsNotFolder',
|
||||||
// Setting this to true may cause some incorrect sorting
|
// Setting this to true may cause some incorrect sorting
|
||||||
@ -1839,15 +1840,15 @@ class PlaybackManager {
|
|||||||
// Only include Photos because we do not handle mixed queues currently
|
// Only include Photos because we do not handle mixed queues currently
|
||||||
MediaTypes: 'Photo',
|
MediaTypes: 'Photo',
|
||||||
Limit: UNLIMITED_ITEMS
|
Limit: UNLIMITED_ITEMS
|
||||||
});
|
}, queryOptions));
|
||||||
} else if (firstItem.Type === 'MusicGenre') {
|
} else if (firstItem.Type === 'MusicGenre') {
|
||||||
promise = getItemsForPlayback(serverId, {
|
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
||||||
GenreIds: firstItem.Id,
|
GenreIds: firstItem.Id,
|
||||||
Filters: 'IsNotFolder',
|
Filters: 'IsNotFolder',
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
SortBy: options.shuffle ? 'Random' : 'SortName',
|
SortBy: options.shuffle ? 'Random' : 'SortName',
|
||||||
MediaTypes: 'Audio'
|
MediaTypes: 'Audio'
|
||||||
});
|
}, queryOptions));
|
||||||
} else if (firstItem.Type === 'Series' || firstItem.Type === 'Season') {
|
} else if (firstItem.Type === 'Series' || firstItem.Type === 'Season') {
|
||||||
const apiClient = ServerConnections.getApiClient(firstItem.ServerId);
|
const apiClient = ServerConnections.getApiClient(firstItem.ServerId);
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import dom from '../scripts/dom';
|
|||||||
import recordingHelper from './recordingcreator/recordinghelper';
|
import recordingHelper from './recordingcreator/recordinghelper';
|
||||||
import ServerConnections from './ServerConnections';
|
import ServerConnections from './ServerConnections';
|
||||||
import toast from './toast/toast';
|
import toast from './toast/toast';
|
||||||
|
import * as userSettings from '../scripts/settings/userSettings';
|
||||||
|
|
||||||
function playAllFromHere(card, serverId, queue) {
|
function playAllFromHere(card, serverId, queue) {
|
||||||
const parent = card.parentNode;
|
const parent = card.parentNode;
|
||||||
@ -177,6 +178,10 @@ function executeAction(card, target, action) {
|
|||||||
|
|
||||||
const item = getItemInfoFromCard(card);
|
const item = getItemInfoFromCard(card);
|
||||||
|
|
||||||
|
const itemsContainer = dom.parentWithClass(card, 'itemsContainer');
|
||||||
|
|
||||||
|
const sortParentId = 'items-' + (item.IsFolder ? item.Id : itemsContainer?.getAttribute('data-parentid')) + '-Folder';
|
||||||
|
|
||||||
const serverId = item.ServerId;
|
const serverId = item.ServerId;
|
||||||
const type = item.Type;
|
const type = item.Type;
|
||||||
|
|
||||||
@ -200,12 +205,17 @@ function executeAction(card, target, action) {
|
|||||||
});
|
});
|
||||||
} else if (action === 'play' || action === 'resume') {
|
} else if (action === 'play' || action === 'resume') {
|
||||||
const startPositionTicks = parseInt(card.getAttribute('data-positionticks') || '0', 10);
|
const startPositionTicks = parseInt(card.getAttribute('data-positionticks') || '0', 10);
|
||||||
|
const sortValues = userSettings.getSortValuesLegacy(sortParentId, 'SortName');
|
||||||
|
|
||||||
if (playbackManager.canPlay(item)) {
|
if (playbackManager.canPlay(item)) {
|
||||||
playbackManager.play({
|
playbackManager.play({
|
||||||
ids: [playableItemId],
|
ids: [playableItemId],
|
||||||
startPositionTicks: startPositionTicks,
|
startPositionTicks: startPositionTicks,
|
||||||
serverId: serverId
|
serverId: serverId,
|
||||||
|
queryOptions: {
|
||||||
|
SortBy: sortValues.sortBy,
|
||||||
|
SortOrder: sortValues.sortOrder
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.warn('Unable to play item', item);
|
console.warn('Unable to play item', item);
|
||||||
|
@ -724,8 +724,13 @@ class ItemsView {
|
|||||||
const currentItem = self.currentItem;
|
const currentItem = self.currentItem;
|
||||||
|
|
||||||
if (currentItem && !self.hasFilters) {
|
if (currentItem && !self.hasFilters) {
|
||||||
|
const values = self.getSortValues();
|
||||||
playbackManager.play({
|
playbackManager.play({
|
||||||
items: [currentItem],
|
items: [currentItem],
|
||||||
|
queryOptions: {
|
||||||
|
SortBy: values.sortBy,
|
||||||
|
SortOrder: values.sortOrder
|
||||||
|
},
|
||||||
autoplay: true
|
autoplay: true
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -960,10 +965,7 @@ class ItemsView {
|
|||||||
|
|
||||||
getSortValues() {
|
getSortValues() {
|
||||||
const basekey = this.getSettingsKey();
|
const basekey = this.getSettingsKey();
|
||||||
return {
|
return userSettings.getSortValuesLegacy(basekey, this.getDefaultSortBy());
|
||||||
sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
|
|
||||||
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultSortBy() {
|
getDefaultSortBy() {
|
||||||
|
@ -622,6 +622,21 @@ export class UserSettings {
|
|||||||
getFilter(key) {
|
getFilter(key) {
|
||||||
return this.get(key, true);
|
return this.get(key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current sort values (Legacy - Non-JSON)
|
||||||
|
* (old views such as list.js [Photos] will
|
||||||
|
* use this one)
|
||||||
|
* @param {string} key - Filter key.
|
||||||
|
* @param {string} defaultSortBy - Default SortBy value.
|
||||||
|
* @return {Object} sortOptions object
|
||||||
|
*/
|
||||||
|
getSortValuesLegacy(key, defaultSortBy) {
|
||||||
|
return {
|
||||||
|
sortBy: this.getFilter(key + '-sortby') || defaultSortBy,
|
||||||
|
sortOrder: this.getFilter(key + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const currentSettings = new UserSettings;
|
export const currentSettings = new UserSettings;
|
||||||
@ -672,3 +687,4 @@ export const customCss = currentSettings.customCss.bind(currentSettings);
|
|||||||
export const disableCustomCss = currentSettings.disableCustomCss.bind(currentSettings);
|
export const disableCustomCss = currentSettings.disableCustomCss.bind(currentSettings);
|
||||||
export const getSavedView = currentSettings.getSavedView.bind(currentSettings);
|
export const getSavedView = currentSettings.getSavedView.bind(currentSettings);
|
||||||
export const saveViewSetting = currentSettings.saveViewSetting.bind(currentSettings);
|
export const saveViewSetting = currentSettings.saveViewSetting.bind(currentSettings);
|
||||||
|
export const getSortValuesLegacy = currentSettings.getSortValuesLegacy.bind(currentSettings);
|
||||||
|
Loading…
Reference in New Issue
Block a user