Fix undefined error in token state sort
This commit is contained in:
parent
d96ec27c88
commit
bbb9279228
@ -206,13 +206,25 @@ function Map({
|
||||
setIsTokenMenuOpen(true);
|
||||
}
|
||||
|
||||
// Sort so vehicles render below other tokens
|
||||
function sortMapTokenStates(a, b) {
|
||||
const tokenA = tokensById[a.tokenId];
|
||||
const tokenB = tokensById[b.tokenId];
|
||||
if (tokenA && tokenB) {
|
||||
return tokenB.isVehicle - tokenA.isVehicle;
|
||||
} else if (tokenA) {
|
||||
return 1;
|
||||
} else if (tokenB) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const mapTokens =
|
||||
mapState &&
|
||||
Object.values(mapState.tokens)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
tokensById[b.tokenId].isVehicle - tokensById[a.tokenId].isVehicle
|
||||
) // Sort so vehicles render below other tokens
|
||||
.sort(sortMapTokenStates)
|
||||
.map((tokenState) => (
|
||||
<MapToken
|
||||
key={tokenState.id}
|
||||
|
Loading…
Reference in New Issue
Block a user