@dansup I've been using the local storage API for so many projects lately, I really think it gets overlooked a lot of the time when it's the ideal solution. This being a great use case!
@dansup how does it sync between a mobile client and a web browser?
@paperdigits It wouldn't.
@dansup fair enough!
@paperdigits I don't feel comfortable logging searches, and that would be required to sync between browsers and apps.
@dansup I understand and appreciate the attention to detail and respect for privacy.
@dansup localStorage is synchronous, loads all content into memory on page navigation (in FF at least), and is capped at 5MB in some browsers. It's good for small data, but you may want to use IndexedDB instead.
@nolan Good idea, thanks for the advice!
@dansup Heads up: I can't remember if it's local storage or another tool, but there is some wonky behavior with private mode on Firefox that I hit when I try to use Standard Notes.
@dansup Downside: Safari is very aggressive about attempts to access localStorage in incognito, so you need to try...catch _everything_. If you write a little wrapper for it, it works out pretty okay.
The API also isn't wonderful, but you can wrap that too and make it nicer.
@zacanger Cool thanks, I'm using typeahead/bloodhound and think it has a localStorage cache.
@dansup It does, and it looks like they safely check if it can be accessed, which means you won't see a bunch of "SecurityError: DOM Exception 18" from folks on Safari in private mode
a) if that''s the only thing you use it for, you'll need to add a GDPR cookie warning just for that
b) if new content related to the search term becomes available, it will not be shown in the cached results
@dansup If you use localStorage, it won't be accessible if a Service Worker comes in your app at some point (which is rather likely to happen). IndexedDb would by my first choice (with https://github.com/jakearchibald/idb-keyval for simple use cases). Also, this read is worth it: https://www.rdegges.com/2018/please-stop-using-local-storage/
@meduz Interesting, thanks for sharing!
Invite-only Mastodon server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!