Updated map state usage to use DB when selecting
This commit is contained in:
parent
53eb9b3c08
commit
265472311e
@ -19,7 +19,7 @@ function EditMapModal({ isOpen, onDone, mapId }) {
|
|||||||
updateMapState,
|
updateMapState,
|
||||||
getMap,
|
getMap,
|
||||||
getMapFromDB,
|
getMapFromDB,
|
||||||
mapStates,
|
getMapStateFromDB,
|
||||||
} = useMapData();
|
} = useMapData();
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@ -34,8 +34,9 @@ function EditMapModal({ isOpen, onDone, mapId }) {
|
|||||||
if (loadingMap?.type === "file" && !loadingMap?.file) {
|
if (loadingMap?.type === "file" && !loadingMap?.file) {
|
||||||
loadingMap = await getMapFromDB(mapId);
|
loadingMap = await getMapFromDB(mapId);
|
||||||
}
|
}
|
||||||
|
const mapState = await getMapStateFromDB(mapId);
|
||||||
setMap(loadingMap);
|
setMap(loadingMap);
|
||||||
setMapState(mapStates.find((state) => state.mapId === mapId));
|
setMapState(mapState);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ function EditMapModal({ isOpen, onDone, mapId }) {
|
|||||||
setMap();
|
setMap();
|
||||||
setMapState();
|
setMapState();
|
||||||
}
|
}
|
||||||
}, [isOpen, mapId, getMapFromDB, mapStates, getMap]);
|
}, [isOpen, mapId, getMapFromDB, getMapStateFromDB, getMap]);
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
setMapSettingChanges({});
|
setMapSettingChanges({});
|
||||||
|
@ -65,6 +65,7 @@ function SelectMapModal({
|
|||||||
updateMaps,
|
updateMaps,
|
||||||
mapsLoading,
|
mapsLoading,
|
||||||
getMapFromDB,
|
getMapFromDB,
|
||||||
|
getMapStateFromDB,
|
||||||
} = useMapData();
|
} = useMapData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -325,12 +326,13 @@ function SelectMapModal({
|
|||||||
// Update last used for cache invalidation
|
// Update last used for cache invalidation
|
||||||
const lastUsed = Date.now();
|
const lastUsed = Date.now();
|
||||||
const map = selectedMaps[0];
|
const map = selectedMaps[0];
|
||||||
|
const mapState = await getMapStateFromDB(map.id);
|
||||||
if (map.type === "file") {
|
if (map.type === "file") {
|
||||||
await updateMap(map.id, { lastUsed });
|
await updateMap(map.id, { lastUsed });
|
||||||
const updatedMap = await getMapFromDB(map.id);
|
const updatedMap = await getMapFromDB(map.id);
|
||||||
onMapChange(updatedMap, selectedMapStates[0]);
|
onMapChange(updatedMap, mapState);
|
||||||
} else {
|
} else {
|
||||||
onMapChange(map, selectedMapStates[0]);
|
onMapChange(map, mapState);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onMapChange(null, null);
|
onMapChange(null, null);
|
||||||
|
Loading…
Reference in New Issue
Block a user