vault/ui/app/lib/local-storage.js
Angel Garbarino b1179db639
Disabling License Banners (#19116)
* work in progress: got the expired banner set with license check

* wip: got the logic for both banners, need to test and write tests

* add notes

* prep for test writing

* test coverage

* add changelog

* clean up

* clarify dismissTypes and conditionals

* updates

* update comment

* update comment

* address pr comments

* update test

* small naming change

* small naming changes

* clean localStorage

* comment clean up

* another comment clean up

* remove meep

* add test coverage for new method in localStorage
2023-02-14 17:00:24 +00:00

29 lines
620 B
JavaScript

export default {
getItem(key) {
var item = window.localStorage.getItem(key);
return item && JSON.parse(item);
},
setItem(key, val) {
window.localStorage.setItem(key, JSON.stringify(val));
},
removeItem(key) {
return window.localStorage.removeItem(key);
},
keys() {
return Object.keys(window.localStorage);
},
cleanUpStorage(string, keyToKeep) {
if (!string) return;
const relevantKeys = this.keys().filter((str) => str.startsWith(string));
relevantKeys?.forEach((key) => {
if (key !== keyToKeep) {
localStorage.removeItem(key);
}
});
},
};