Skip to content

Commit

Permalink
filter optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashmi-278 committed Feb 21, 2024
1 parent b5b19f6 commit 9b64b8b
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions daostar-website/src/components/ExplorePage/ExplorePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,22 @@ import "./ExplorePage.css";
import { InputGroup, Button } from "@blueprintjs/core";

// Prelimnary check filter, if a DAO has no name, it won't be displayed
// export const filterRegistrations = (registration, filterVal = "test") => {
// if (!registration.daoName) {
// return false;
// }
// if (filterVal !== "") {
// return registration.daoName.toLowerCase().includes(filterVal.toLowerCase());
// }
// return true;
// };

export const filterRegistrations = (registration, filterVal) => {
// Check if daoName is present
if (!registration.daoName) {
export const filterRegistrations = (registration, filterVal = "") => {
// Check if daoName is present and not empty
if (!registration.daoName || registration.daoName.trim() === "") {
return false;
}
if (filterVal !== "") {
const daoNameLower = registration.daoName.toLowerCase();

const filterWords = ["scam", "test", "fuck"];

for (const filterWord of filterWords) {
if (daoNameLower.includes(filterWord)) {
return false; // Exclude if it contains a filter word
}
}
return registration.daoName.toLowerCase().includes(filterVal.toLowerCase());
}
const daoNameLower = registration.daoName.toLowerCase();
const filterWords = ["scam", "test", "fuck"];


// Check for excluded words
if (filterWords.some(filterWord => daoNameLower.includes(filterWord))) {
return false;
}

return true; // Include if it passes all checks
// Check if a specific filter value is provided and included in the daoName
return filterVal === "" || daoNameLower.includes(filterVal.toLowerCase());
};

// Network Filter for EVM Chains
Expand Down

0 comments on commit 9b64b8b

Please sign in to comment.