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

View File

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

View File

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

View File

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

View File

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