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

Limit $recentSearches State to Hold a Maximum of 5 Entries #70

Open
babblebey opened this issue May 24, 2024 · 2 comments
Open

Limit $recentSearches State to Hold a Maximum of 5 Entries #70

babblebey opened this issue May 24, 2024 · 2 comments
Assignees
Labels
↗️ medium priority This issue is crucial 🤲 help wanted Extra attention is needed ✨ enhancement New feature or request

Comments

@babblebey
Copy link
Member

Currently, the $recentSearches state holds all the recent searches without any limit. To improve user experience and ensure that the list of recent searches remains manageable, we need to limit the $recentSearches state to hold a maximum of 5 entries. When a new word is added and the limit is reached, the oldest entry should be removed to make space for the new one.

Current Implementation

The current implementation does not limit the number of recent searches stored. It can be found at https://github.com/devjargons/jargons.dev/blob/main/src/lib/stores/search.js

Task

Modify the $addToRecentSearchesFn function to ensure that the $recentSearches state holds a maximum of 5 entries. If the limit is reached, remove the oldest entry before adding a new one.

Implementation Steps

  1. Check the number of entries in the $recentSearches state.
  2. If the number of entries is 5 or more, remove the oldest entry.
  3. Add the new entry to the $recentSearches state.
  4. Update the local storage with the modified state.

Acceptance Criteria

  • The $recentSearches state should hold a maximum of 5 entries.
  • When a new entry is added and the limit is reached, the oldest entry should be removed.
  • The local storage should be updated accordingly.

Additional Information

  • This enhancement will be implemented in the lib/stores/search.js file where the $addToRecentSearchesFn function is defined.
@babblebey babblebey added ✨ enhancement New feature or request 🤲 help wanted Extra attention is needed ↗️ medium priority This issue is crucial labels May 24, 2024
@AyendiSimeon1
Copy link

AyendiSimeon1 commented Nov 20, 2024

Hi @babblebey, i would like to contribute to this issue and help resolve it. Please let me know how I can get started.

@babblebey
Copy link
Member Author

Hey @AyendiSimeon1, let's goooooo 💪🏾

Feel free to write a comment here if you have any questions or need any help at all with this, I can share some thoughts 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
↗️ medium priority This issue is crucial 🤲 help wanted Extra attention is needed ✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants