Skip to content

Commit 4f202e5

Browse files
committed
removed unnecessary default filter requests on pages that don't have a category set
1 parent 19eeb9b commit 4f202e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/assets/javascripts/filters.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
88
const $saveButton = $form.find('.filter-save');
99
const $isDefaultCheckbox = $form.find('.filter-is-default');
1010
const categoryId = $isDefaultCheckbox.val()?.toString();
11-
let defaultFilter = await QPixel.defaultFilter(categoryId);
11+
let defaultFilter = categoryId ? await QPixel.defaultFilter(categoryId) : null;
1212
const $deleteButton = $form.find('.filter-delete');
1313

1414
// Enables/Disables Save & Delete buttons programatically
@@ -51,7 +51,7 @@ document.addEventListener('DOMContentLoaded', () => {
5151
}
5252

5353
async function initializeSelect() {
54-
defaultFilter = await QPixel.defaultFilter(categoryId);
54+
defaultFilter = categoryId ? await QPixel.defaultFilter(categoryId) : null;
5555
$isDefaultCheckbox.prop('checked', defaultFilter === $select.val());
5656
const filters = await QPixel.filters();
5757

@@ -139,7 +139,8 @@ document.addEventListener('DOMContentLoaded', () => {
139139
}
140140

141141
await QPixel.setFilter($select.val()?.toString(), filter, categoryId, $isDefaultCheckbox.prop('checked'));
142-
defaultFilter = await QPixel.defaultFilter(categoryId);
142+
143+
defaultFilter = categoryId ? await QPixel.defaultFilter(categoryId) : null;
143144

144145
// Reinitialize to get new options
145146
await initializeSelect();

0 commit comments

Comments
 (0)