MISC: Handle error when getting save data (#1241)

This commit is contained in:
catloversg
2024-05-09 16:19:30 +07:00
committed by GitHub
parent bfb9841832
commit aef362204d
4 changed files with 47 additions and 4 deletions
+11 -1
View File
@@ -39,6 +39,7 @@ import { useBoolean } from "../hooks";
import { ComparisonIcon } from "./ComparisonIcon";
import { SaveData } from "../../../types";
import { handleGetSaveDataError } from "../../../Netscript/ErrorMessages";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -131,7 +132,16 @@ export const ImportSave = (props: { saveData: SaveData; automatic: boolean }): J
return Promise.resolve();
}
if (props.saveData) fetchData();
if (props.saveData) {
fetchData().catch((error) => {
handleGoBack();
// We cannot show dialog box in this screen (due to "withPopups = false"), so we will try showing it with a
// delay. 1 second is usually enough to go back to other normal screens that allow showing popups.
setTimeout(() => {
handleGetSaveDataError(error);
}, 1000);
});
}
}, [props.saveData]);
if (!importData || !currentData) return <></>;