@@ -20,10 +20,13 @@ import WineSelector from './WineSelector'
2020import { SelectField } from 'frontend/components/UI'
2121import { useTranslation } from 'react-i18next'
2222import ThirdPartyDialog from './ThirdPartyDialog'
23+ import {
24+ closeInstallGameModal ,
25+ useInstallGameModal
26+ } from 'frontend/state/InstallGameModal'
2327
2428type Props = {
2529 appName : string
26- backdropClick : ( ) => void
2730 runner : Runner
2831 gameInfo ?: GameInfo | null
2932}
@@ -35,12 +38,7 @@ export type AvailablePlatforms = {
3538 icon : IconDefinition
3639} [ ]
3740
38- export default React . memo ( function InstallModal ( {
39- appName,
40- backdropClick,
41- runner,
42- gameInfo = null
43- } : Props ) {
41+ function InstallModal ( { appName, runner, gameInfo = null } : Props ) {
4442 const { platform } = useContext ( ContextProvider )
4543 const { t } = useTranslation ( 'gamepage' )
4644
@@ -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