Commit
·
212aba3
1
Parent(s):
6999d55
Add boolean filter toggle functionality
Browse files- Add TOGGLE_BOOLEAN_FILTER action to reducer
- Export toggleBooleanFilter action for reasoning filter controls
- Remove unused boolean filtering logic from modelMatchesFilters
frontend/src/pages/LeaderboardPage/components/Leaderboard/context/LeaderboardContext.js
CHANGED
@@ -125,24 +125,6 @@ const modelMatchesFilters = (model, filters) => {
|
|
125 |
if (!modelName.includes(searchLower)) return false;
|
126 |
}
|
127 |
|
128 |
-
// Boolean filters
|
129 |
-
if (filters.booleanFilters.length > 0) {
|
130 |
-
return filters.booleanFilters.every((filter) => {
|
131 |
-
const filterValue = typeof filter === "object" ? filter.value : filter;
|
132 |
-
|
133 |
-
// Maintainer's Highlight keeps positive logic
|
134 |
-
if (filterValue === "is_official_provider") {
|
135 |
-
return model.features[filterValue];
|
136 |
-
}
|
137 |
-
|
138 |
-
// For all other filters, invert the logic
|
139 |
-
if (filterValue === "is_not_available_on_hub") {
|
140 |
-
return model.features[filterValue];
|
141 |
-
}
|
142 |
-
|
143 |
-
return !model.features[filterValue];
|
144 |
-
});
|
145 |
-
}
|
146 |
|
147 |
return true;
|
148 |
};
|
@@ -289,6 +271,21 @@ const reducer = (state, action) => {
|
|
289 |
},
|
290 |
};
|
291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
case "SET_DISPLAY_OPTION":
|
293 |
return {
|
294 |
...state,
|
@@ -673,6 +670,7 @@ const LeaderboardProvider = ({ children }) => {
|
|
673 |
dispatch({ type: "SET_LOADING", payload: loading }),
|
674 |
setError: (error) => dispatch({ type: "SET_ERROR", payload: error }),
|
675 |
setFilter: (key, value) => dispatch({ type: "SET_FILTER", key, value }),
|
|
|
676 |
setDisplayOption: (key, value) =>
|
677 |
dispatch({ type: "SET_DISPLAY_OPTION", key, value }),
|
678 |
togglePinnedModel: (modelKey) =>
|
|
|
125 |
if (!modelName.includes(searchLower)) return false;
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
return true;
|
130 |
};
|
|
|
271 |
},
|
272 |
};
|
273 |
|
274 |
+
case "TOGGLE_BOOLEAN_FILTER":
|
275 |
+
const { filter } = action;
|
276 |
+
const currentFilters = state.filters.booleanFilters;
|
277 |
+
const newBooleanFilters = currentFilters.includes(filter)
|
278 |
+
? currentFilters.filter((f) => f !== filter)
|
279 |
+
: [...currentFilters, filter];
|
280 |
+
|
281 |
+
return {
|
282 |
+
...state,
|
283 |
+
filters: {
|
284 |
+
...state.filters,
|
285 |
+
booleanFilters: newBooleanFilters,
|
286 |
+
},
|
287 |
+
};
|
288 |
+
|
289 |
case "SET_DISPLAY_OPTION":
|
290 |
return {
|
291 |
...state,
|
|
|
670 |
dispatch({ type: "SET_LOADING", payload: loading }),
|
671 |
setError: (error) => dispatch({ type: "SET_ERROR", payload: error }),
|
672 |
setFilter: (key, value) => dispatch({ type: "SET_FILTER", key, value }),
|
673 |
+
toggleBooleanFilter: (filter) => dispatch({ type: "TOGGLE_BOOLEAN_FILTER", filter }),
|
674 |
setDisplayOption: (key, value) =>
|
675 |
dispatch({ type: "SET_DISPLAY_OPTION", key, value }),
|
676 |
togglePinnedModel: (modelKey) =>
|