24 Commits

Author SHA1 Message Date
Sukhwinder Dhillon
cf9ffe29bf Revert "storage.js: Use substring instead of startsWith on strings"
This reverts commit 22805514843424f9040ed92af86691a053d2c463.
2022-06-13 15:50:52 +02:00
Johannes Meyer
5849c06314 storage.js: Don't try and allow to register events for non-local backends 2019-07-30 08:17:29 +02:00
Eric Lippmann
a1a18feb04 js/storage: Allow to set the storage backend 2019-07-30 08:14:49 +02:00
Johannes Meyer
2179518904 storage.js: Properly check if we have any keys left before clearing the storage 2019-07-26 07:36:17 +02:00
Johannes Meyer
8893db0cbc js: Drop a StorageAwareMap entirely from storage if all keys expired 2019-07-18 07:43:42 +02:00
Johannes Meyer
cfa3af51db storage.js: Don't return in StorageAwareMap.forEach 2019-07-17 13:12:41 +02:00
Johannes Meyer
c976eb48c9 storage.js: Properly handle invalid values 2019-07-17 13:12:41 +02:00
Johannes Meyer
2280551484 storage.js: Use substring instead of startsWith on strings
IE11 doesn't support startsWith..
2019-07-17 13:12:41 +02:00
Johannes Meyer
f11de266f4 storage.js: Avoid to call JSON.parse with an empty string
IE11 seems not to like this..
2019-07-17 13:12:41 +02:00
Johannes Meyer
9561057b81 storage.js: Allow to subscribe with multiple handlers to the same key 2019-07-17 13:12:41 +02:00
Johannes Meyer
2bf050f57d storage.js: Don't use the native event mechanism but a simple callback handling 2019-07-17 13:12:41 +02:00
Johannes Meyer
2fd7ba5aed storage.js: Utilize a single event listener for all storage events
It doesn't make sense to register an event listener for every
created storage instance. They're all using entirely different
keys after all.
2019-07-17 13:12:41 +02:00
Johannes Meyer
2ac848828a storage.js: Prevent conflicts with other apps accessing the same storage 2019-07-17 13:12:41 +02:00
Johannes Meyer
0f16e20d92 storage.js: Write null instead of undefined to the storage
`undefined` causes the key to be ignored by JSON.stringify
2019-07-17 13:12:41 +02:00
Johannes Meyer
383895fd92 storage.js: Pass the value to event subscribers of StorageAwareMap 2019-07-17 13:12:41 +02:00
Johannes Meyer
8937e11a09 storage.js: Properly handle if keys are entirely removed 2019-07-17 13:12:41 +02:00
Johannes Meyer
363486277b storage.js: Rename Storage.subscribe to onChange 2019-07-17 13:12:41 +02:00
Johannes Meyer
c5beabf891 storage.js: Cleanup StorageAwareMap key corpses after 90 days 2019-07-17 13:12:41 +02:00
Johannes Meyer
cbd1e1bb92 storage.js: Drop StorageAwareSet and replace it with StorageAwareMap 2019-07-17 13:12:41 +02:00
Johannes Meyer
8377a2d096 storage.js: Don't use .bind() to define a callbacks context 2019-07-17 13:12:41 +02:00
Johannes Meyer
03fc052749 storage.js: Directly use scope window to access localStorage 2019-07-17 13:12:41 +02:00
Johannes Meyer
95dee43f5b storage.js: Just use a factory to create behavior storages 2019-07-17 13:12:41 +02:00
Johannes Meyer
3b7a1a5ab4 storage.js: Add method on to StorageAwareSet 2019-07-17 13:12:41 +02:00
Johannes Meyer
e2cddc2d46 js: Introduce storage.js, a localStorage abstraction layer 2019-07-17 13:12:41 +02:00