Move measurement options to map settings

This commit is contained in:
Mitchell McCaffrey
2021-02-10 19:59:15 +11:00
parent 19def8cdb0
commit 96298e8943
15 changed files with 153 additions and 210 deletions

View File

@@ -14,7 +14,13 @@ import { getGridDefaultInset } from "../helpers/grid";
import useResponsiveLayout from "../hooks/useResponsiveLayout";
function EditMapModal({ isOpen, onDone, mapId }) {
const { updateMap, updateMapState, getMapFromDB, mapStates } = useMapData();
const {
updateMap,
updateMapState,
getMap,
getMapFromDB,
mapStates,
} = useMapData();
const [isLoading, setIsLoading] = useState(true);
const [map, setMap] = useState();
@@ -23,7 +29,12 @@ function EditMapModal({ isOpen, onDone, mapId }) {
useEffect(() => {
async function loadMap() {
setIsLoading(true);
setMap(await getMapFromDB(mapId));
let loadingMap = getMap(mapId);
// Ensure file is loaded for map
if (loadingMap?.type === "file" && !loadingMap?.file) {
loadingMap = await getMapFromDB(mapId);
}
setMap(loadingMap);
setMapState(mapStates.find((state) => state.mapId === mapId));
setIsLoading(false);
}