Fixed bug that caused a crash when a map was deleted with unsaved changes

This commit is contained in:
Mitchell McCaffrey 2020-09-11 11:24:25 +10:00
parent 73180ee1cd
commit 529fd2caae
2 changed files with 10 additions and 6 deletions

View File

@ -102,7 +102,7 @@ function MapSettings({
</Box>
<Flex
mt={2}
mb={map.type === "default" ? 2 : 0}
mb={mapEmpty || map.type === "default" ? 2 : 0}
sx={{ alignItems: "flex-end" }}
>
<Box sx={{ width: "50%" }}>
@ -154,8 +154,9 @@ function MapSettings({
key={quality.id}
value={quality.id}
disabled={
quality.id !== "original" &&
!map.resolutions[quality.id]
mapEmpty ||
(quality.id !== "original" &&
!map.resolutions[quality.id])
}
>
{quality.name}

View File

@ -174,9 +174,9 @@ function SelectMapModal({
async function handleMapRemove(id) {
await removeMap(id);
setSelectedMapId(null);
setMapSettingChanges({});
setMapStateSettingChanges({});
setSelectedMapId(null);
// Removed the map from the map screen if needed
if (currentMap && currentMap.id === selectedMapId) {
onMapChange(null, null);
@ -265,8 +265,11 @@ function SelectMapModal({
}
}
const selectedMapWithChanges = { ...selectedMap, ...mapSettingChanges };
const selectedMapStateWithChanges = {
const selectedMapWithChanges = selectedMap && {
...selectedMap,
...mapSettingChanges,
};
const selectedMapStateWithChanges = selectedMapState && {
...selectedMapState,
...mapStateSettingChanges,
};