Skip to content

Commit

Permalink
refactor: Use forEach for portability
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrylyzo committed Oct 10, 2023
1 parent b81342d commit fc37f82
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/filtermenu/filtermenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,27 @@ function onInputCommand(e) {
function saveValues(context, settings, settingsKey, setfilters) {
// Video type
const videoTypes = [];
for (const elem of context.querySelectorAll('.chkVideoTypeFilter')) {
context.querySelectorAll('.chkVideoTypeFilter').forEach(elem => {
if (elem.checked) {
videoTypes.push(elem.getAttribute('data-filter'));
}
}
});

// Series status
const seriesStatuses = [];
for (const elem of context.querySelectorAll('.chkSeriesStatus')) {
context.querySelectorAll('.chkSeriesStatus').forEach(elem => {
if (elem.checked) {
seriesStatuses.push(elem.getAttribute('data-filter'));
}
}
});

// Genres
const genres = [];
for (const elem of context.querySelectorAll('.chkGenreFilter')) {
context.querySelectorAll('.chkGenreFilter').forEach(elem => {
if (elem.checked) {
genres.push(elem.getAttribute('data-filter'));
}
}
});

if (setfilters) {
setfilters((prevState) => ({
Expand All @@ -149,13 +149,13 @@ function saveValues(context, settings, settingsKey, setfilters) {
GenreIds: genres.join(',')
}));
} else {
for (const elem of context.querySelectorAll('.simpleFilter')) {
context.querySelectorAll('.simpleFilter').forEach(elem => {
if (elem.tagName === 'INPUT') {
setBasicFilter(context, settingsKey + '-filter-' + elem.getAttribute('data-settingname'), elem);
} else {
setBasicFilter(context, settingsKey + '-filter-' + elem.getAttribute('data-settingname'), elem.querySelector('input'));
}
}
});

userSettings.setFilter(settingsKey + '-filter-GenreIds', genres.join(','));
}
Expand Down

0 comments on commit fc37f82

Please sign in to comment.