Clear map actions on reset

This commit is contained in:
Mitchell McCaffrey 2021-02-22 17:14:12 +11:00
parent d244471870
commit 53d4e05502
5 changed files with 11 additions and 10 deletions

View File

@ -32,7 +32,7 @@ function Map({
onMapTokenStateChange, onMapTokenStateChange,
onMapTokenStateRemove, onMapTokenStateRemove,
onMapChange, onMapChange,
onMapStateChange, onMapReset,
onMapDraw, onMapDraw,
onMapDrawUndo, onMapDrawUndo,
onMapDrawRedo, onMapDrawRedo,
@ -153,7 +153,7 @@ function Map({
const mapControls = ( const mapControls = (
<MapControls <MapControls
onMapChange={onMapChange} onMapChange={onMapChange}
onMapStateChange={onMapStateChange} onMapReset={onMapReset}
currentMap={map} currentMap={map}
currentMapState={mapState} currentMapState={mapState}
onSelectedToolChange={setSelectedToolId} onSelectedToolChange={setSelectedToolId}

View File

@ -24,7 +24,7 @@ import useSetting from "../../hooks/useSetting";
function MapContols({ function MapContols({
onMapChange, onMapChange,
onMapStateChange, onMapReset,
currentMap, currentMap,
currentMapState, currentMapState,
selectedToolId, selectedToolId,
@ -81,7 +81,7 @@ function MapContols({
component: ( component: (
<SelectMapButton <SelectMapButton
onMapChange={onMapChange} onMapChange={onMapChange}
onMapStateChange={onMapStateChange} onMapReset={onMapReset}
currentMap={currentMap} currentMap={currentMap}
currentMapState={currentMapState} currentMapState={currentMapState}
disabled={disabledControls.includes("map")} disabled={disabledControls.includes("map")}

View File

@ -9,7 +9,7 @@ import { useAuth } from "../../contexts/AuthContext";
function SelectMapButton({ function SelectMapButton({
onMapChange, onMapChange,
onMapStateChange, onMapReset,
currentMap, currentMap,
currentMapState, currentMapState,
disabled, disabled,
@ -43,7 +43,7 @@ function SelectMapButton({
isOpen={isModalOpen} isOpen={isModalOpen}
onDone={handleDone} onDone={handleDone}
onMapChange={onMapChange} onMapChange={onMapChange}
onMapStateChange={onMapStateChange} onMapReset={onMapReset}
currentMap={currentMap} currentMap={currentMap}
/> />
</> </>

View File

@ -50,7 +50,7 @@ function SelectMapModal({
isOpen, isOpen,
onDone, onDone,
onMapChange, onMapChange,
onMapStateChange, onMapReset,
// The map currently being view in the map screen // The map currently being view in the map screen
currentMap, currentMap,
}) { }) {
@ -290,7 +290,7 @@ function SelectMapModal({
const newState = await resetMap(id); const newState = await resetMap(id);
// Reset the state of the current map if needed // Reset the state of the current map if needed
if (currentMap && currentMap.id === id) { if (currentMap && currentMap.id === id) {
onMapStateChange(newState); onMapReset(newState);
} }
} }
setIsLoading(false); setIsLoading(false);

View File

@ -229,8 +229,9 @@ function NetworkedMapAndTokens({ session }) {
await loadAssetManifestFromMap(newMap, newMapState); await loadAssetManifestFromMap(newMap, newMapState);
} }
function handleMapStateChange(newMapState) { function handleMapReset(newMapState) {
setCurrentMapState(newMapState, true, true); setCurrentMapState(newMapState, true, true);
setMapActions(defaultMapActions);
} }
const [mapActions, setMapActions] = useState(defaultMapActions); const [mapActions, setMapActions] = useState(defaultMapActions);
@ -569,7 +570,7 @@ function NetworkedMapAndTokens({ session }) {
onMapTokenStateChange={handleMapTokenStateChange} onMapTokenStateChange={handleMapTokenStateChange}
onMapTokenStateRemove={handleMapTokenStateRemove} onMapTokenStateRemove={handleMapTokenStateRemove}
onMapChange={handleMapChange} onMapChange={handleMapChange}
onMapStateChange={handleMapStateChange} onMapReset={handleMapReset}
onMapDraw={handleMapDraw} onMapDraw={handleMapDraw}
onMapDrawUndo={handleMapDrawUndo} onMapDrawUndo={handleMapDrawUndo}
onMapDrawRedo={handleMapDrawRedo} onMapDrawRedo={handleMapDrawRedo}