From ec4732b15b0317f9dc921231b83dc509ed001cc8 Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 5 Apr 2019 23:50:38 -0400 Subject: [PATCH] refactor: selfEntity patch --- client/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/index.js b/client/index.js index 9f4a438..202cf83 100644 --- a/client/index.js +++ b/client/index.js @@ -183,8 +183,11 @@ function onMessage({type, payload}) { switch (type) { case 'state-update': const patch = unpacker.unpack(payload); - if (payload.selfEntity) { - selfEntity = payload.selfEntity; + for (const step of patch) { + const {op, path, value} = step; + if ('add' === op && '/selfEntity' === path) { + selfEntity = value; + } } stateSynchronizer.patchState(patch); dirty = true;