mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 01:48:16 -07:00
Backport pull request #6274 from jellyfin-web/release-10.10.z
Make filtering local to each device
Original-merge: ad8868a996
Merged-by: thornbill <thornbill@users.noreply.github.com>
Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
parent
1bbae0ef23
commit
fc314790d3
@ -17,6 +17,26 @@ function saveServerPreferences(instance) {
|
||||
instance.saveTimeout = setTimeout(onSaveTimeout.bind(instance), 50);
|
||||
}
|
||||
|
||||
const allowedSortSettings = ['SortBy', 'SortOrder'];
|
||||
|
||||
const filterSettingsPostfix = '-filter';
|
||||
const allowedFilterSettings = [
|
||||
'Filters', 'HasSubtitles', 'HasTrailer', 'HasSpecialFeature',
|
||||
'HasThemeSong', 'HasThemeVideo', 'Genres', 'OfficialRatings',
|
||||
'Tags', 'VideoTypes', 'IsSD', 'IsHD', 'Is4K', 'Is3D',
|
||||
'IsFavorite', 'IsMissing', 'IsUnaired', 'ParentIndexNumber',
|
||||
'SeriesStatus', 'Years'
|
||||
];
|
||||
|
||||
function filterQuerySettings(query, allowedItems) {
|
||||
return Object.keys(query)
|
||||
.filter(field => allowedItems.includes(field))
|
||||
.reduce((acc, field) => {
|
||||
acc[field] = query[field];
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
const defaultSubtitleAppearanceSettings = {
|
||||
verticalPosition: -3
|
||||
};
|
||||
@ -521,13 +541,17 @@ export class UserSettings {
|
||||
* @return {Query} Query.
|
||||
*/
|
||||
loadQuerySettings(key, query) {
|
||||
let values = this.get(key);
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
return Object.assign(query, values);
|
||||
let sortSettings = this.get(key);
|
||||
let filterSettings = this.get(key + filterSettingsPostfix, false);
|
||||
|
||||
if (sortSettings) {
|
||||
sortSettings = filterQuerySettings(JSON.parse(sortSettings), allowedSortSettings);
|
||||
}
|
||||
if (filterSettings) {
|
||||
filterSettings = filterQuerySettings(JSON.parse(filterSettings), allowedFilterSettings);
|
||||
}
|
||||
|
||||
return query;
|
||||
return Object.assign(query, sortSettings, filterSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -536,7 +560,11 @@ export class UserSettings {
|
||||
* @param {Object} query - Query.
|
||||
*/
|
||||
saveQuerySettings(key, query) {
|
||||
return this.set(key, JSON.stringify(query));
|
||||
const sortSettings = filterQuerySettings(query, allowedSortSettings);
|
||||
const filterSettings = filterQuerySettings(query, allowedFilterSettings);
|
||||
|
||||
this.set(key, JSON.stringify(sortSettings));
|
||||
this.set(key + filterSettingsPostfix, JSON.stringify(filterSettings), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user