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

Improved Article Finder Searchbar with added Autocomplete #5741

Conversation

prathamVaidya
Copy link
Contributor

What this PR does

Closes #649

This PR improves the Article Finder Searchbar UI and adds autocomplete functionality to the finder.

Screenshots

Before:

image

After:

image

screen-recording-2024-03-31-19.56.webm

Comment on lines 113 to 119
export const fetchArticleAutocompleteResults = async (keyword, wiki) => {
const query = keywordAutocompleteGenerator(keyword);

return queryUrl(mediawikiApiBase(wiki.language, wiki.project), query).then((data) => {
return data.query.search.map(item => item.title);
});
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use await if the function is marked as async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using await and return is redundant because then it will resolve the promise and again convert it into a promise because an async function returns a promise anyways.
See:
https://stackoverflow.com/a/44806250

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant in place of the then, the return is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you meant the then I used on queryUrl then Yes I do have used await when I called this method but I have used then trying to abstract the API logic and its returned structure. If I remove it then every where I use it I need to know the underlying structure of the response JSON.

@prathamVaidya
Copy link
Contributor Author

@TheTrio @ragesoss this is ready for review.

@TheTrio
Copy link
Contributor

TheTrio commented Apr 3, 2024 via email

@ragesoss
Copy link
Member

ragesoss commented Apr 9, 2024

Nice, this works pretty smoothly!

@ragesoss
Copy link
Member

ragesoss commented Apr 9, 2024

thanks much for the code review @TheTrio !

@ragesoss ragesoss merged commit 86e83ce into WikiEducationFoundation:master Apr 9, 2024
1 check passed
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.

Article title fields should autocomplete
3 participants