Make nested player proxies of arrays as well as objects

This commit is contained in:
thepaperpilot 2022-05-02 08:53:58 -05:00
parent f94c4a966f
commit 2d9de00424

View file

@ -51,7 +51,11 @@ const playerHandler: ProxyHandler<Record<PropertyKey, any>> = {
} }
const value = target[ProxyState][key]; const value = target[ProxyState][key];
if (key !== "value" && isPlainObject(value) && !(value instanceof Decimal)) { if (
key !== "value" &&
(isPlainObject(value) || Array.isArray(value)) &&
!(value instanceof Decimal)
) {
if (value !== target[key]?.[ProxyState]) { if (value !== target[key]?.[ProxyState]) {
const path = [...target[ProxyPath], key]; const path = [...target[ProxyPath], key];
target[key] = new Proxy({ [ProxyState]: value, [ProxyPath]: path }, playerHandler); target[key] = new Proxy({ [ProxyState]: value, [ProxyPath]: path }, playerHandler);