finished impl local storage lazy init cache objects
@@ -26,7 +26,7 @@ export function getReadUris() {
try {
readUrisCache = JSON.parse(readUrisString);
} catch (e) {
- clearReadUris();
+ localStorage.removeItem(READ_URIS);
readUrisCache = [];
}
} else {
@@ -38,21 +38,11 @@ export function getReadUris() {
}
export function isUriRead(uri) {
- if (!readUrisCache) {
- let readUrisString = localStorage.getItem(READ_URIS);
-
- if (readUrisString) {
- readUrisCache = JSON.parse(readUrisString);
- }
- }
-
- if (readUrisCache) {
- for (const readUri of readUrisCache) {
+ for (const readUri of getReadUris()) {
if (readUri === uri) {
return true;
}
}
- }
return false;
}
@@ -86,7 +76,7 @@ export function getClosedConnUris() {
try {
closedConnUrisCache = JSON.parse(closedConnUrisString);
} catch (e) {
- clearClosedConnUris();
+ localStorage.removeItem(CLOSED_CONN_URIS);
closedConnUrisCache = [];
}
} else {
