Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
grafixeyehero committed Sep 17, 2023
1 parent afd14e9 commit 95f8faf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 73 deletions.
49 changes: 14 additions & 35 deletions src/components/filtermenu/filtermenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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 = [];
Expand All @@ -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 = [];
Expand All @@ -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++) {
Expand Down Expand Up @@ -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();
Expand Down
17 changes: 4 additions & 13 deletions src/components/sortmenu/sortmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -104,7 +95,7 @@ class SortMenu {
}

if (submitted) {
saveValues(dlg, options.settingsKey, options.setSortValues);
saveValues(dlg, options.settingsKey);
resolve();
return;
}
Expand Down
25 changes: 7 additions & 18 deletions src/components/viewSettings/viewSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -137,7 +126,7 @@ class ViewSettings {
}

if (submitted) {
saveValues(dlg, options.settings, options.settingsKey, options.setviewsettings);
saveValues(dlg, options.settings, options.settingsKey);
return resolve();
}

Expand Down
7 changes: 0 additions & 7 deletions src/components/viewSettings/viewSettings.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@
<span>${GroupBySeries}</span>
</label>
</div>

<div class="checkboxContainer viewSetting viewSetting-checkboxContainer hide chkCardLayoutContainer" data-settingname="cardLayout">
<label>
<input is="emby-checkbox" type="checkbox" class="chkEnableCardLayout" />
<span>${EnableCardLayout}</span>
</label>
</div>
</div>
</form>
</div>
Expand Down

0 comments on commit 95f8faf

Please sign in to comment.