diff --git a/src/components/filtermenu/filtermenu.js b/src/components/filtermenu/filtermenu.js index d7e9c8765073..4ae7d8dc0efe 100644 --- a/src/components/filtermenu/filtermenu.js +++ b/src/components/filtermenu/filtermenu.js @@ -102,8 +102,16 @@ function onInputCommand(e) { break; } } -function saveValues(context, settings, settingsKey, setfilters) { + +function saveValues(context, settings, settingsKey) { let elems = context.querySelectorAll('.simpleFilter'); + for (let i = 0, length = elems.length; i < length; i++) { + if (elems[i].tagName === 'INPUT') { + setBasicFilter(context, settingsKey + '-filter-' + elems[i].getAttribute('data-settingname'), elems[i]); + } else { + setBasicFilter(context, settingsKey + '-filter-' + elems[i].getAttribute('data-settingname'), elems[i].querySelector('input')); + } + } // Video type const videoTypes = []; @@ -114,6 +122,7 @@ function saveValues(context, settings, settingsKey, setfilters) { videoTypes.push(elems[i].getAttribute('data-filter')); } } + userSettings.setFilter(settingsKey + '-filter-VideoTypes', videoTypes.join(',')); // Series status const seriesStatuses = []; @@ -124,6 +133,7 @@ function saveValues(context, settings, settingsKey, setfilters) { seriesStatuses.push(elems[i].getAttribute('data-filter')); } } + userSettings.setFilter(`${settingsKey}-filter-SeriesStatus`, seriesStatuses.join(',')); // Genres const genres = []; @@ -134,40 +144,9 @@ function saveValues(context, settings, settingsKey, setfilters) { genres.push(elems[i].getAttribute('data-filter')); } } - - if (setfilters) { - setfilters((prevState) => ({ - ...prevState, - StartIndex: 0, - IsPlayed: context.querySelector('.chkPlayed').checked, - IsUnplayed: context.querySelector('.chkUnplayed').checked, - IsFavorite: context.querySelector('.chkFavorite').checked, - IsResumable: context.querySelector('.chkResumable').checked, - Is4K: context.querySelector('.chk4KFilter').checked, - IsHD: context.querySelector('.chkHDFilter').checked, - IsSD: context.querySelector('.chkSDFilter').checked, - Is3D: context.querySelector('.chk3DFilter').checked, - VideoTypes: videoTypes.join(','), - SeriesStatus: seriesStatuses.join(','), - HasSubtitles: context.querySelector('.chkSubtitle').checked, - HasTrailer: context.querySelector('.chkTrailer').checked, - HasSpecialFeature: context.querySelector('.chkSpecialFeature').checked, - HasThemeSong: context.querySelector('.chkThemeSong').checked, - HasThemeVideo: context.querySelector('.chkThemeVideo').checked, - GenreIds: genres.join(',') - })); - } else { - for (let i = 0, length = elems.length; i < length; i++) { - if (elems[i].tagName === 'INPUT') { - setBasicFilter(context, settingsKey + '-filter-' + elems[i].getAttribute('data-settingname'), elems[i]); - } else { - setBasicFilter(context, settingsKey + '-filter-' + elems[i].getAttribute('data-settingname'), elems[i].querySelector('input')); - } - } - - userSettings.setFilter(settingsKey + '-filter-GenreIds', genres.join(',')); - } + userSettings.setFilter(settingsKey + '-filter-GenreIds', genres.join(',')); } + function bindCheckboxInput(context, on) { const elems = context.querySelectorAll('.checkboxList-verticalwrap'); for (let i = 0, length = elems.length; i < length; i++) { @@ -297,7 +276,7 @@ class FilterMenu { } if (submitted) { - saveValues(dlg, options.settings, options.settingsKey, options.setfilters); + saveValues(dlg, options.settings, options.settingsKey); return resolve(); } return resolve(); diff --git a/src/components/sortmenu/sortmenu.js b/src/components/sortmenu/sortmenu.js index 65aef222e9d8..f145ccf3d358 100644 --- a/src/components/sortmenu/sortmenu.js +++ b/src/components/sortmenu/sortmenu.js @@ -37,18 +37,9 @@ function fillSortBy(context, options) { }).join(''); } -function saveValues(context, settingsKey, setSortValues) { - if (setSortValues) { - setSortValues((prevState) => ({ - ...prevState, - StartIndex: 0, - SortBy: context.querySelector('.selectSortBy').value, - SortOrder: context.querySelector('.selectSortOrder').value - })); - } else { - userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value); - userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value); - } +function saveValues(context, settingsKey) { + userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value); + userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value); } class SortMenu { @@ -104,7 +95,7 @@ class SortMenu { } if (submitted) { - saveValues(dlg, options.settingsKey, options.setSortValues); + saveValues(dlg, options.settingsKey); resolve(); return; } diff --git a/src/components/viewSettings/viewSettings.js b/src/components/viewSettings/viewSettings.js index f5cb864206a5..9c4b64710f60 100644 --- a/src/components/viewSettings/viewSettings.js +++ b/src/components/viewSettings/viewSettings.js @@ -29,24 +29,13 @@ function initEditor(context, settings) { context.querySelector('.selectImageType').value = settings.imageType || 'primary'; } -function saveValues(context, settings, settingsKey, setviewsettings) { - if (setviewsettings) { - setviewsettings((prevState) => ({ - ...prevState, - StartIndex: 0, - imageType: context.querySelector('.selectImageType').value, - showTitle: context.querySelector('.chkShowTitle').checked || false, - showYear: context.querySelector('.chkShowYear').checked || false, - cardLayout: context.querySelector('.chkEnableCardLayout').checked || false - })); - } else { - const elems = context.querySelectorAll('.viewSetting-checkboxContainer'); - for (const elem of elems) { - userSettings.set(settingsKey + '-' + elem.getAttribute('data-settingname'), elem.querySelector('input').checked); - } - - userSettings.set(settingsKey + '-imageType', context.querySelector('.selectImageType').value); +function saveValues(context, settings, settingsKey) { + const elems = context.querySelectorAll('.viewSetting-checkboxContainer'); + for (const elem of elems) { + userSettings.set(settingsKey + '-' + elem.getAttribute('data-settingname'), elem.querySelector('input').checked); } + + userSettings.set(settingsKey + '-imageType', context.querySelector('.selectImageType').value); } function centerFocus(elem, horiz, on) { @@ -137,7 +126,7 @@ class ViewSettings { } if (submitted) { - saveValues(dlg, options.settings, options.settingsKey, options.setviewsettings); + saveValues(dlg, options.settings, options.settingsKey); return resolve(); } diff --git a/src/components/viewSettings/viewSettings.template.html b/src/components/viewSettings/viewSettings.template.html index ddee9536baf1..df9767fb75bc 100644 --- a/src/components/viewSettings/viewSettings.template.html +++ b/src/components/viewSettings/viewSettings.template.html @@ -35,13 +35,6 @@ ${GroupBySeries} - -
- -