Skip to content

Instantly share code, notes, and snippets.

@epsalt
Created May 8, 2022 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epsalt/5df1bde648197f90f3243962ec937e18 to your computer and use it in GitHub Desktop.
Save epsalt/5df1bde648197f90f3243962ec937e18 to your computer and use it in GitHub Desktop.
const events = [
{ title: "Appointment" },
{ title: "FW: Appointment" },
{ title: "//Appointment" },
];
const listFilter = (event) => {
const filters = ["FW:", "//"];
let found = false;
for (const f of filters) {
if (event.title.search(f) > -1) {
found = true;
}
}
return found;
};
const regexFilter = (event) => {
if (event.title.match(/FW:|\/\//)) {
return true;
}
return false;
};
console.log("list filter");
events.map((event) => {
console.log(event.title, regexFilter(event));
});
console.log("\n");
console.log("regular expression filter");
events.map((event) => {
console.log(event.title, regexFilter(event));
});
@EvadingRye
Copy link

Thanks again Evan! It works! I used your second example and then gave the Dashboard a couple days to figure itself out because for some reason it would first only hide events with a title that had "//" in it while still showing events with "FW:". However after 10 minutes or so it would refresh and it would hide "FW:" as well, and then revert back after 10 mins or more. But it's now been 12 hours and it seems to be stable haha.

My theory is there's some update interval in the code I'm using (not your code) that it kept reverting to due to cache or something I don't know. I'm not going to question it too much because it looks like it works! Knock on wood.

@epsalt
Copy link
Author

epsalt commented May 10, 2022

Great to hear! What you described sounds like a caching issue to me but hard to say without looking deeper into what the library is doing. If you want to add other things to the regular expression, sites like this one help a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment