Fix custom token loading for players

This commit is contained in:
Mitchell McCaffrey 2021-06-06 11:03:07 +10:00
parent 9d9fd5b753
commit 7d1cff7358
2 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import { useEffect, useState, useRef, useCallback } from "react";
import cloneDeep from "lodash.clonedeep";
import useDebounce from "./useDebounce";
import { diff, applyChanges } from "../helpers/diff";
@ -70,7 +71,7 @@ function useNetworkedState(
}
dirtyRef.current = false;
forceUpdateRef.current = false;
lastSyncedStateRef.current = debouncedState;
lastSyncedStateRef.current = cloneDeep(debouncedState);
}
}, [
session.socket,

View File

@ -91,15 +91,15 @@ function NetworkedMapAndTokens({ session }) {
function addAssetsIfNeeded(assets) {
setAssetManifest((prevManifest) => {
if (prevManifest?.assets) {
let newManifset = { ...prevManifest };
let newAssets = { ...prevManifest.assets };
for (let asset of assets) {
const id = asset.id;
const exists = id in prevManifest.assets;
const exists = id in newAssets;
if (!exists) {
newManifset[id] = asset;
newAssets[id] = asset;
}
}
return newManifset;
return { ...prevManifest, assets: newAssets };
}
return prevManifest;
});