Skip to content

Commit b91d67f

Browse files
authored
reload checks when reloading due to missing ios/android directory (#1033)
Currently, when the `ios`/`android` directory is missing, the user is prompted to reload the IDE, but that action doesn't re-check for this directory, resulting in the same error even if the directory was created. This PR fixes that. ### How Has This Been Tested: - open a project - remove the `ios` directory - open Radon IDE with an `ios` simulator - the "`ios` directory is missing" error should appear - restore the `ios` directory - click reload - the error should not appear again
1 parent 6aaef43 commit b91d67f

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

packages/vscode-extension/src/webview/hooks/useBuildErrorAlert.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ import { useLaunchConfig } from "../providers/LaunchConfigProvider";
88
import { useDependencies } from "../providers/DependenciesProvider";
99
import { DevicePlatform } from "../../common/DeviceManager";
1010

11+
type LogsButtonDestination = "build" | "extension";
12+
1113
function BuildErrorActions({
1214
logsButtonDestination,
15+
onReload,
1316
}: {
14-
logsButtonDestination?: "build" | "extension";
17+
logsButtonDestination?: LogsButtonDestination;
18+
onReload?: () => void;
1519
}) {
1620
const { project } = useProject();
1721
const { openModal } = useModal();
@@ -40,9 +44,7 @@ function BuildErrorActions({
4044
</IconButton>
4145
<IconButton
4246
type="secondary"
43-
onClick={() => {
44-
project.restart(false);
45-
}}
47+
onClick={onReload}
4648
tooltip={{ label: "Reload IDE", side: "bottom" }}>
4749
<span className="codicon codicon-refresh" />
4850
</IconButton>
@@ -52,11 +54,15 @@ function BuildErrorActions({
5254

5355
export function useBuildErrorAlert(shouldDisplayAlert: boolean) {
5456
const { ios, xcodeSchemes, eas } = useLaunchConfig();
55-
const { dependencies } = useDependencies();
56-
const { projectState } = useProject();
57+
const { dependencies, runDiagnostics } = useDependencies();
58+
const { projectState, project } = useProject();
59+
60+
let onReload = () => {
61+
project.restart(false);
62+
};
63+
let logsButtonDestination: LogsButtonDestination | undefined = undefined;
5764

5865
let description = "Open build logs to find out what went wrong.";
59-
let actions = <BuildErrorActions />;
6066

6167
if (!ios?.scheme && xcodeSchemes.length > 1) {
6268
description = `Your project uses multiple build schemas. Currently used scheme: '${xcodeSchemes[0]}'. You can change it in the launch configuration.`;
@@ -68,6 +74,10 @@ export function useBuildErrorAlert(shouldDisplayAlert: boolean) {
6874
) {
6975
description =
7076
'Your project does not have "android" directory. If this is an Expo project, you may need to run `expo prebuild` to generate missing files, or configure external build source using launch configuration.';
77+
onReload = () => {
78+
runDiagnostics();
79+
project.restart(false);
80+
};
7181
}
7282

7383
if (
@@ -76,6 +86,10 @@ export function useBuildErrorAlert(shouldDisplayAlert: boolean) {
7686
) {
7787
description =
7888
'Your project does not have "ios" directory. If this is an Expo project, you may need to run `expo prebuild` to generate missing files, or configure external build source using launch configuration.';
89+
onReload = () => {
90+
runDiagnostics();
91+
project.restart(false);
92+
};
7993
}
8094

8195
const isEasBuild =
@@ -89,9 +103,13 @@ export function useBuildErrorAlert(shouldDisplayAlert: boolean) {
89103
} else {
90104
description = "Your project EAS build has failed, see extension logs to see what went wrong.";
91105
}
92-
actions = <BuildErrorActions logsButtonDestination="extension" />;
106+
logsButtonDestination = "extension";
93107
}
94108

109+
const actions = (
110+
<BuildErrorActions logsButtonDestination={logsButtonDestination} onReload={onReload} />
111+
);
112+
95113
const buildErrorAlert = {
96114
id: "build-error-alert",
97115
title: "Cannot run project",

0 commit comments

Comments
 (0)