Client is laggy.
The entities store is updated every time any table is updated.
Due to how the tables are structured, with CarriedBy, indicating which pod a machine belongs in, not being a key there does not seem to be a way for us to filter to only get the content of the players pod from the indexer.
Continuation of https://github.com/Moving-Castles/this-cursed-machine/issues/262
Problem
Client is laggy. The
entities
store is updated every time any table is updated.Due to how the tables are structured, with
CarriedBy
, indicating which pod a machine belongs in, not being a key there does not seem to be a way for us to filter to only get the content of the players pod from the indexer.The loading problem in https://github.com/Moving-Castles/this-cursed-machine/issues/262 was improved by not relying on the update streams to set the initial local state. Rather using this: https://github.com/Moving-Castles/this-cursed-machine/blob/main/packages/client/src/svelte/modules/systems/initEntities.ts
And then ignoring updates where the new and old values are the same: https://github.com/Moving-Castles/this-cursed-machine/blob/c64eed60170bae370356150e9ddeeba465b2f41f/packages/client/src/svelte/modules/systems/createComponentSystem.ts#L14
Problems are:
entitites
store is large and growingHow do we ignore updates that are not relevant to the player?
The heavy part of the update is this: https://github.com/Moving-Castles/this-cursed-machine/blob/c64eed60170bae370356150e9ddeeba465b2f41f/packages/client/src/svelte/modules/systems/createComponentSystem.ts#L25
Solutions / improvements
initEntites
, only write the data that is relevant to the player.createComponentSystem
, abort before updating store if the data is not relevant