mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-27 08:10:34 +00:00
Make filtering local to device
This commit is contained in:
parent
18ea570ea1
commit
c0a9f8b544
@ -17,6 +17,24 @@ 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', 'IsHD', 'Is4K', 'Is3D', '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,15 +539,17 @@ export class UserSettings {
|
||||
* @return {Query} Query.
|
||||
*/
|
||||
loadQuerySettings(key, query) {
|
||||
let values = this.get(key);
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
delete values.NameStartsWith;
|
||||
delete values.NameLessThan;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -538,22 +558,11 @@ export class UserSettings {
|
||||
* @param {Object} query - Query.
|
||||
*/
|
||||
saveQuerySettings(key, query) {
|
||||
const allowedFields = [
|
||||
'SortBy', 'SortOrder', 'Filters', 'HasSubtitles',
|
||||
'HasTrailer', 'HasSpecialFeature', 'HasThemeSong',
|
||||
'HasThemeVideo', 'Genres', 'OfficialRatings',
|
||||
'Tags', 'VideoTypes', 'IsHD', 'Is4K', 'Is3D',
|
||||
'Years'
|
||||
];
|
||||
const sortSettings = filterQuerySettings(query, allowedSortSettings);
|
||||
const filterSettings = filterQuerySettings(query, allowedFilterSettings);
|
||||
|
||||
const newQuery = Object.keys(query)
|
||||
.filter(field => allowedFields.includes(field))
|
||||
.reduce((acc, field) => {
|
||||
acc[field] = query[field];
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return this.set(key, JSON.stringify(newQuery));
|
||||
this.set(key, JSON.stringify(sortSettings));
|
||||
this.set(key + filterSettingsPostfix, JSON.stringify(filterSettings), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user