@@ -7,19 +7,12 @@ import {
77} from 'renderer/actions/install-path.utils' ;
88import settings from 'renderer/rendererSettings' ;
99import { Directories } from 'renderer/utils/Directories' ;
10- import { Button , ButtonType } from 'renderer/components/Button' ;
1110import * as os from 'os' ;
1211import { ipcRenderer } from 'electron' ;
1312import channels from 'common/channels' ;
14- import { Simulators , TypeOfSimulator } from 'renderer/utils/SimManager' ;
13+ import { TypeOfSimulator } from 'renderer/utils/SimManager' ;
1514import { useErrors } from './useErrors' ;
16-
17- type Error = {
18- condition : boolean ;
19- title : string ;
20- description : React . ReactNode ;
21- actions : React . ReactNode ;
22- } ;
15+ import { errorConfig } from './errorConfig' ;
2316
2417const platform = os . platform ( ) ;
2518const reload = ( ) => ipcRenderer . send ( channels . window . reload ) ;
@@ -74,131 +67,25 @@ export const ErrorModal = (): JSX.Element => {
7467 reload ( ) ;
7568 } ;
7669
77- const errors : Error [ ] = [
78- {
79- condition : noSimInstalled ,
80- title : 'No simulator detected' ,
81- description : (
82- < >
83- We could not find an installed simulator. Please select for which simulator you’d like to manage your addons.
84- You can change your selection any time in the settings.
85- </ >
86- ) ,
87- actions : (
88- < >
89- < Button type = { ButtonType . Neutral } onClick = { ( ) => enableSimulator ( Simulators . Msfs2020 ) } >
90- Microsoft Flight Simulator 2020
91- </ Button >
92- < Button type = { ButtonType . Neutral } onClick = { ( ) => enableSimulator ( Simulators . Msfs2024 ) } >
93- Microsoft Flight Simulator 2024
94- </ Button >
95- </ >
96- ) ,
97- } ,
98- {
99- condition : msfs2020BasePathError ,
100- title : 'MSFS 2020 base path missing' ,
101- description : (
102- < >
103- We couldn’t determine the correct MSFS 2020 base path. Please select it manually. < br />
104- { platform === 'linux'
105- ? 'Usually: ~/.local/share/Steam/steamapps/compatdata/<APPID>/pfx/drive_c/users/steamuser/AppData/Microsoft Flight Simulator/'
106- : 'Usually: "%LOCALAPPDATA%\\Packages\\Microsoft.FlightSimulator_8wekyb3d8bbwe\\LocalCache"' }
107- </ >
108- ) ,
109- actions : (
110- < >
111- < Button type = { ButtonType . Neutral } onClick = { ( ) => handleSelectSimulatorBasePath ( Simulators . Msfs2020 ) } >
112- Select Path
113- </ Button >
114- < Button type = { ButtonType . Neutral } onClick = { ( ) => handleSimulatorNotInstalled ( Simulators . Msfs2020 ) } >
115- I don’t have MSFS 2020 installed
116- </ Button >
117- </ >
118- ) ,
119- } ,
70+ const errors = errorConfig (
71+ platform ,
12072 {
121- condition : msfs2024BasePathError ,
122- title : 'MSFS 2024 base path missing' ,
123- description : (
124- < >
125- We couldn’t determine the correct MSFS 2024 base path. Please select it manually. < br />
126- { platform === 'linux'
127- ? 'You can usually find it somewhere here:\n~/.local/share/Steam/steamapps/compatdata/<APPID>/pfx/drive_c/users/steamuser/AppData/Microsoft Flight Simulator 2024/'
128- : 'You can usually find it somewhere here:\n"%LOCALAPPDATA%\\Packages\\Microsoft.Limitless_8wekyb3d8bbwe\\LocalCache"' }
129- </ >
130- ) ,
131- actions : (
132- < >
133- < Button type = { ButtonType . Neutral } onClick = { ( ) => handleSelectSimulatorBasePath ( Simulators . Msfs2024 ) } >
134- Select Path
135- </ Button >
136- < Button type = { ButtonType . Neutral } onClick = { ( ) => handleSimulatorNotInstalled ( Simulators . Msfs2024 ) } >
137- I don’t have MSFS 2024 installed
138- </ Button >
139- </ >
140- ) ,
73+ noSimInstalled,
74+ msfs2020BasePathError,
75+ msfs2024BasePathError,
76+ msfs2020InstallError,
77+ msfs2024InstallError,
78+ tempLocationError,
14179 } ,
14280 {
143- condition : msfs2020InstallError ,
144- title : 'MSFS 2020 Community folder not found' ,
145- description : (
146- < >
147- Your MSFS 2020 Community folder is set to:
148- < pre className = "mx-auto my-2 w-3/5 overflow-x-auto rounded-lg bg-gray-700 px-6 py-2.5 text-center font-mono text-2xl" >
149- { Directories . installLocation ( Simulators . Msfs2020 ) || 'not set' }
150- </ pre >
151- but we couldn’t find it there. Please set the correct location before continuing.
152- </ >
153- ) ,
154- actions : (
155- < Button type = { ButtonType . Neutral } onClick = { ( ) => handleSelectInstallPath ( Simulators . Msfs2020 ) } >
156- Select Path
157- </ Button >
158- ) ,
81+ enableSimulator,
82+ handleSelectSimulatorBasePath,
83+ handleSimulatorNotInstalled,
84+ handleSelectInstallPath,
85+ handleSelectTempLocation,
86+ resetTempLocation,
15987 } ,
160- {
161- condition : msfs2024InstallError ,
162- title : 'MSFS 2024 Community folder not found' ,
163- description : (
164- < >
165- Your MSFS 2024 Community folder is set to:
166- < pre className = "mx-auto my-2 w-3/5 overflow-x-auto rounded-lg bg-gray-700 px-6 py-2.5 text-center font-mono text-2xl" >
167- { Directories . installLocation ( Simulators . Msfs2024 ) || 'not set' }
168- </ pre >
169- but we couldn’t find it there. Please set the correct location before continuing.
170- </ >
171- ) ,
172- actions : (
173- < Button type = { ButtonType . Neutral } onClick = { ( ) => handleSelectInstallPath ( Simulators . Msfs2024 ) } >
174- Select Path
175- </ Button >
176- ) ,
177- } ,
178- {
179- condition : tempLocationError ,
180- title : 'Temporary folder not found' ,
181- description : (
182- < >
183- Your location for temporary folders is set to:
184- < pre className = "mx-auto my-2 w-3/5 overflow-x-auto rounded-lg bg-gray-700 px-6 py-2.5 text-center font-mono text-2xl" >
185- { settings . get ( 'mainSettings.tempLocation' ) || 'not set' }
186- </ pre >
187- but we couldn’t find it there. Please set the correct location before continuing.
188- </ >
189- ) ,
190- actions : (
191- < >
192- < Button type = { ButtonType . Neutral } onClick = { handleSelectTempLocation } >
193- Select Path
194- </ Button >
195- < Button type = { ButtonType . Neutral } onClick = { resetTempLocation } >
196- Reset
197- </ Button >
198- </ >
199- ) ,
200- } ,
201- ] ;
88+ ) ;
20289
20390 const activeError = errors . find ( ( e ) => e . condition ) ;
20491
0 commit comments