@@ -21,10 +21,13 @@ import { SelectField } from 'frontend/components/UI'
2121import { useTranslation } from 'react-i18next'
2222import ThirdPartyDialog from './ThirdPartyDialog'
2323import { MenuItem } from '@mui/material'
24+ import {
25+ closeInstallGameModal ,
26+ useInstallGameModal
27+ } from 'frontend/state/InstallGameModal'
2428
2529type Props = {
2630 appName : string
27- backdropClick : ( ) => void
2831 runner : Runner
2932 gameInfo ?: GameInfo | null
3033}
@@ -36,12 +39,7 @@ export type AvailablePlatforms = {
3639 icon : IconDefinition
3740} [ ]
3841
39- export default React . memo ( function InstallModal ( {
40- appName,
41- backdropClick,
42- runner,
43- gameInfo = null
44- } : Props ) {
42+ function InstallModal ( { appName, runner, gameInfo = null } : Props ) {
4543 const { platform } = useContext ( ContextProvider )
4644 const { t } = useTranslation ( 'gamepage' )
4745
@@ -155,10 +153,12 @@ export default React.memo(function InstallModal({
155153 const showDownloadDialog = ! isSideload && gameInfo
156154 const isThirdPartyManagedApp = gameInfo && ! ! gameInfo . thirdPartyManagedApp
157155
156+ const closeModal = ( ) => closeInstallGameModal ( )
157+
158158 return (
159159 < div className = "InstallModal" >
160160 < Dialog
161- onClose = { backdropClick }
161+ onClose = { closeModal }
162162 showCloseButton
163163 className = "InstallModal__dialog"
164164 >
@@ -169,7 +169,7 @@ export default React.memo(function InstallModal({
169169 winePrefix = { winePrefix }
170170 wineVersion = { wineVersion }
171171 availablePlatforms = { availablePlatforms }
172- backdropClick = { backdropClick }
172+ backdropClick = { closeModal }
173173 platformToInstall = { platformToInstall }
174174 gameInfo = { gameInfo }
175175 crossoverBottle = { crossoverBottle }
@@ -197,7 +197,7 @@ export default React.memo(function InstallModal({
197197 winePrefix = { winePrefix }
198198 wineVersion = { wineVersion }
199199 availablePlatforms = { availablePlatforms }
200- backdropClick = { backdropClick }
200+ backdropClick = { closeModal }
201201 platformToInstall = { platformToInstall }
202202 gameInfo = { gameInfo }
203203 crossoverBottle = { crossoverBottle }
@@ -223,7 +223,7 @@ export default React.memo(function InstallModal({
223223 winePrefix = { winePrefix }
224224 wineVersion = { wineVersion }
225225 availablePlatforms = { availablePlatforms }
226- backdropClick = { backdropClick }
226+ backdropClick = { closeModal }
227227 platformToInstall = { platformToInstall }
228228 appName = { appName }
229229 crossoverBottle = { crossoverBottle }
@@ -246,4 +246,20 @@ export default React.memo(function InstallModal({
246246 </ Dialog >
247247 </ div >
248248 )
249- } )
249+ }
250+
251+ export function InstallGameWrapper ( ) {
252+ const installGameModalState = useInstallGameModal ( )
253+
254+ if ( ! installGameModalState . isOpen ) {
255+ return < > </ >
256+ }
257+
258+ return (
259+ < InstallModal
260+ appName = { installGameModalState . appName ! }
261+ runner = { installGameModalState . runner ! }
262+ gameInfo = { installGameModalState . gameInfo }
263+ />
264+ )
265+ }
0 commit comments