Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify filter to work on selection change without button click (Fix #55) #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ST-KO
Copy link
Contributor

@ST-KO ST-KO commented Sep 4, 2024

Summary

This pull request address issue #55, modifies the filter functionality to trigger automatically on change.

Changes

  • Implemented a 'useEffect' hook in '_index.tsx' file that listens for changes to the filter criteria.

Related Issues

Screen Recording

Screen.Recording.2024-09-04.at.1.mp4

Copy link

netlify bot commented Sep 4, 2024

👷 Deploy request for gitbegin pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ccbdee8

Copy link
Contributor

@omjogani omjogani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, Thanks for the Video Demonstration!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ST-KO This is not the ideal way of working with immediate searches/filters, We must be a debounce (delay) before firing a query. Consider typing paragraphs/digits for some reason, it will be flooded with tons of requests as you type the text in the box, kinda like a DDOS attack if many people are using it.

We must debounce for at least 500 milliseconds (standard). That would prevent tons of queries from being fired to API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly what I was going to suggest

@@ -146,7 +146,35 @@ export default function Index() {
}
}, [initialIssues, showBookmarked, isBookmarked])

const handleLanguageChange = (selectedLanguage: any) => {
useEffect(() => {
const formData = new FormData()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend creating a custom hook that contains all the logic of the filter and exposes only the required stuff. That way it would be easy to test (I recommend writing tests too, if you can 😉 ) and we don't need to touch _index.tsx file while caring about filtration.

@dotslashbit
Copy link
Contributor

@ST-KO if you want any help please reach out to @omjogani I'm sure his experience can help you learn and implement these things.

If you are hesitant to write tests, then you can leave it but if you want to learn and implement test, then @omjogani is there to help you.

Remember there's no rush, take your time ☺️

@ST-KO
Copy link
Contributor Author

ST-KO commented Sep 4, 2024

@dotslashbit @omjogani That makes more sense. Thank you so much for explaining my mistake guys. I knew it shouldn't be that simple 😅 .

As for custom hook, I might take some time as I have never written custom hook before and have to learn it first. At the mean time, if you want to assign this to another contributor, I am totally ok with that. But I will still be working on it.

I'll also reach out to @omjogani for help if I am stuck. Thanks guys ☺️

@dotslashbit
Copy link
Contributor

@ST-KO no no there's no rush, please take your time, learn and implement.
We are here to help 😁

@omjogani
Copy link
Contributor

omjogani commented Sep 4, 2024

@dotslashbit @omjogani That makes more sense. Thank you so much for explaining my mistake guys. I knew it shouldn't be that simple 😅 .

As for custom hook, I might take some time as I have never written custom hook before and have to learn it first. At the mean time, if you want to assign this to another contributor, I am totally ok with that. But I will still be working on it.

I'll also reach out to @omjogani for help if I am stuck. Thanks guys ☺️

Open Source is all about learning and applying, We want you to implement it and comment here if you face any difficulties, more than happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify Filter to work without clicking on the filter button
3 participants