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

fix: don't allow saved searches over limit (resolves #206) #212

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions resources/assets/scripts/routes/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export default {
const tags = document.querySelectorAll('.filters input:checked');
let savedSearches = localStorage.getItem('saved-searches');
savedSearches = savedSearches ? JSON.parse(savedSearches) : {};
if (Object.keys(savedSearches).length === 50) {
addNotification(
__('Search not saved', 'coop-library'),
__('You have reached the maximum amount of saved searches (50). To save more, you must delete some saved searches.', 'coop-library'),
'error'
);
return false;
}
const now = Date.now();
const term = document.querySelector('.filters input[name="s"]').value;
const name = input ? input : sprintf(__('Saved search for “%s”', 'coop-library'), term);
Expand Down