diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index e056dc8..a27ee9c 100644 --- a/src/network/NetworkedMapAndTokens.js +++ b/src/network/NetworkedMapAndTokens.js @@ -50,7 +50,7 @@ function NetworkedMapAndTokens({ session }) { "mapId" ); const [assetManifest, setAssetManifest] = useNetworkedState( - [], + null, session, "manifest", 100, @@ -94,15 +94,17 @@ function NetworkedMapAndTokens({ session }) { function addAssetIfNeeded(asset) { // Asset needs updating - const exists = assetManifest.some((oldAsset) => + const exists = assetManifest?.some((oldAsset) => compareAssets(oldAsset, asset) ); - const needsUpdate = assetManifest.some((oldAsset) => + const needsUpdate = assetManifest?.some((oldAsset) => assetNeedsUpdate(oldAsset, asset) ); if (!exists || needsUpdate) { setAssetManifest((prevAssets) => [ - ...prevAssets.filter((prevAsset) => !compareAssets(prevAsset, asset)), + ...(prevAssets || []).filter( + (prevAsset) => !compareAssets(prevAsset, asset) + ), asset, ]); } @@ -286,7 +288,7 @@ function NetworkedMapAndTokens({ session }) { } function handleMapTokenStateChange(change) { - if (currentMapState === null) { + if (!currentMapState) { return; } setCurrentMapState((prevMapState) => ({