Send a map clear before replace to ensure new state isn't show on old image
This commit is contained in:
parent
db8e0c14fb
commit
a4e1a898ad
@ -251,6 +251,22 @@ function Map({
|
||||
</Box>
|
||||
);
|
||||
|
||||
const mapDrawing = (
|
||||
<MapDrawing
|
||||
width={map ? map.width : 0}
|
||||
height={map ? map.height : 0}
|
||||
selectedTool={selectedTool}
|
||||
shapes={drawnShapes}
|
||||
onShapeAdd={handleShapeAdd}
|
||||
onShapeRemove={handleShapeRemove}
|
||||
brushColor={brushColor}
|
||||
useGridSnapping={useBrushGridSnapping}
|
||||
gridSize={gridSizeNormalized}
|
||||
useBrushBlending={useBrushBlending}
|
||||
useBrushGesture={useBrushGesture}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
@ -282,21 +298,9 @@ function Map({
|
||||
paddingBottom: `${(1 / aspectRatio) * 100}%`,
|
||||
}}
|
||||
/>
|
||||
{mapImage}
|
||||
<MapDrawing
|
||||
width={map ? map.width : 0}
|
||||
height={map ? map.height : 0}
|
||||
selectedTool={selectedTool}
|
||||
shapes={drawnShapes}
|
||||
onShapeAdd={handleShapeAdd}
|
||||
onShapeRemove={handleShapeRemove}
|
||||
brushColor={brushColor}
|
||||
useGridSnapping={useBrushGridSnapping}
|
||||
gridSize={gridSizeNormalized}
|
||||
useBrushBlending={useBrushBlending}
|
||||
useBrushGesture={useBrushGesture}
|
||||
/>
|
||||
{mapTokens}
|
||||
{map && mapImage}
|
||||
{map && mapDrawing}
|
||||
{map && mapTokens}
|
||||
</Box>
|
||||
</Box>
|
||||
<MapControls
|
||||
|
@ -141,7 +141,7 @@ function SelectMapModal({
|
||||
});
|
||||
// Removed the map from the map screen if needed
|
||||
if (currentMap && currentMap.id === selectedMap.id) {
|
||||
onMapChange(null);
|
||||
onMapChange(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,8 +165,7 @@ function SelectMapModal({
|
||||
if (selectedMap) {
|
||||
let currentMapState =
|
||||
(await db.table("states").get(selectedMap.id)) || defaultMapState;
|
||||
onMapStateChange(currentMapState);
|
||||
onMapChange(selectedMap);
|
||||
onMapChange(selectedMap, currentMapState);
|
||||
onDone();
|
||||
}
|
||||
onDone();
|
||||
|
@ -48,9 +48,13 @@ function Game() {
|
||||
}
|
||||
}, [debouncedMapState]);
|
||||
|
||||
function handleMapChange(newMap) {
|
||||
function handleMapChange(newMap, newMapState) {
|
||||
setMapState(newMapState);
|
||||
setMap(newMap);
|
||||
for (let peer of Object.values(peers)) {
|
||||
// Clear the map so the new map state isn't shown on an old map
|
||||
peer.connection.send({ id: "map", data: null });
|
||||
peer.connection.send({ id: "mapState", data: newMapState });
|
||||
peer.connection.send({ id: "map", data: newMap });
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user