summaryrefslogtreecommitdiff
path: root/packages/web-util/src/utils/observable.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/web-util/src/utils/observable.ts')
-rw-r--r--packages/web-util/src/utils/observable.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/web-util/src/utils/observable.ts b/packages/web-util/src/utils/observable.ts
index 01e655eaa..16a33ae72 100644
--- a/packages/web-util/src/utils/observable.ts
+++ b/packages/web-util/src/utils/observable.ts
@@ -118,6 +118,7 @@ export function localStorageMap(): ObservableMap<string, string> {
const total = localStorage.length;
return {
next() {
+ if (index === total) return { done: true, value: undefined };
const key = localStorage.key(index);
if (key === null) {
//we are going from 0 until last, this should not happen
@@ -128,7 +129,6 @@ export function localStorageMap(): ObservableMap<string, string> {
//the key exist, this should not happen
throw Error("value cant be null");
}
- if (index == total) return { done: true, value: [key, item] };
index = index + 1;
return { done: false, value: [key, item] };
},
@@ -165,12 +165,12 @@ export function localStorageMap(): ObservableMap<string, string> {
const total = localStorage.length;
return {
next() {
+ if (index === total) return { done: true, value: undefined };
const key = localStorage.key(index);
if (key === null) {
//we are going from 0 until last, this should not happen
throw Error("key cant be null");
}
- if (index == total) return { done: true, value: key };
index = index + 1;
return { done: false, value: key };
},
@@ -185,6 +185,7 @@ export function localStorageMap(): ObservableMap<string, string> {
const total = localStorage.length;
return {
next() {
+ if (index === total) return { done: true, value: undefined };
const key = localStorage.key(index);
if (key === null) {
//we are going from 0 until last, this should not happen
@@ -195,7 +196,6 @@ export function localStorageMap(): ObservableMap<string, string> {
//the key exist, this should not happen
throw Error("value cant be null");
}
- if (index == total) return { done: true, value: item };
index = index + 1;
return { done: false, value: item };
},
@@ -247,11 +247,11 @@ function onBrowserStorageUpdate(cb: (changes: Changes) => void): void {
export function browserStorageMap(
backend: ObservableMap<string, string>,
): ObservableMap<string, string> {
- getAllContent().then((content) => {
+ getAllContent().then(content => {
Object.entries(content ?? {}).forEach(([k, v]) => {
backend.set(k, v as string);
});
- });
+ })
backend.onAnyUpdate(async () => {
const result: Record<string, string> = {};