Skip to content

Commit

Permalink
fix: don't allow saved searches over limit (resolves #206) (#212)
Browse files Browse the repository at this point in the history
* fix: don't allow searches to be saved when limit is reached

Resolves #206

* fix: adjust title of notification
  • Loading branch information
Ned Zimmerman authored Mar 10, 2020
1 parent 0a14fdc commit dccd6c6
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit dccd6c6

Please sign in to comment.