diff --git a/src/core/ui/components/AddonPage.tsx b/src/core/ui/components/AddonPage.tsx index b4201d3..a906494 100644 --- a/src/core/ui/components/AddonPage.tsx +++ b/src/core/ui/components/AddonPage.tsx @@ -67,7 +67,6 @@ export default function AddonPage({ card: CardComponent, ...pr data={data} estimatedItemSize={136} ListHeaderComponent={headerElement} - onLoad={console.log} contentContainerStyle={{ paddingBottom: 90, paddingHorizontal: 5 }} renderItem={({ item }: any) => ( diff --git a/src/lib/api/storage/new.ts b/src/lib/api/storage/new.ts index 5e479f7..b48ccf8 100644 --- a/src/lib/api/storage/new.ts +++ b/src/lib/api/storage/new.ts @@ -31,22 +31,30 @@ function createFileBackend(filePath: string, dflt = {} as T): StorageBackend< } function _createProxy(target: any, path: string[], emitter: Emitter): any { + // cache the children proxies so proxy.child === proxy.child (yields the same value) + const objChildrens = new WeakMap(); + return new Proxy(target, { get(target, prop: string) { if ((prop as unknown) === emitterSymbol) return emitter; const newPath = [...path, prop]; - const value: any = target[prop]; + let value: any = target[prop]; + + if (value && typeof value === "object") { + const origValue = value; + value = objChildrens.get(origValue); + if (!value) { + value = _createProxy(value, newPath, emitter); + objChildrens.set(origValue, value!); + } + } if (value != null) { emitter.emit("GET", { path: newPath, value, }); - if (typeof value === "object") { - return _createProxy(value, newPath, emitter); - } - return value; } return value;