Skip to content

Commit a361058

Browse files
committed
A bit of refactor of the new code
1 parent fbbe2ef commit a361058

File tree

2 files changed

+26
-48
lines changed

2 files changed

+26
-48
lines changed

src/frontend/screens/Game/GamePage/components/MainButton.tsx

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,7 @@ const MainButton = ({ gameInfo, handlePlay, handleInstall }: Props) => {
7474
)
7575
}
7676

77-
function showAltPlayAction() {
78-
if (
79-
is.syncing ||
80-
is.installingRedist ||
81-
is.installingWinetricksPackages ||
82-
is.launching ||
83-
is.playing
84-
) {
85-
return false
86-
}
87-
88-
return true
89-
}
90-
91-
function getAltPlayLabel() {
77+
function altPlayAction() {
9278
if (
9379
is.syncing ||
9480
is.installingRedist ||
@@ -99,20 +85,20 @@ const MainButton = ({ gameInfo, handlePlay, handleInstall }: Props) => {
9985
return <></>
10086
}
10187

102-
if (verboseLogs) {
103-
return (
104-
<span className="buttonWithIcon">
105-
<PlayArrow data-icon="play" />
106-
{t('label.playing.start')}
107-
</span>
108-
)
109-
}
88+
const label = verboseLogs
89+
? t('label.playing.start')
90+
: t('label.playing.start_with_logs', 'Play Now (with logs)')
11091

11192
return (
112-
<span className="buttonWithIcon">
113-
<PlayArrow data-icon="play" />
114-
{t('label.playing.start_with_logs', 'Play Now (with logs)')}
115-
</span>
93+
<button className="button altPlay is-success">
94+
<ArrowBackIosNew />
95+
<a className="button" onClick={handleAltLaunch}>
96+
<span className="buttonWithIcon">
97+
<PlayArrow data-icon="play" />
98+
{label}
99+
</span>
100+
</a>
101+
</button>
116102
)
117103
}
118104

@@ -175,6 +161,18 @@ const MainButton = ({ gameInfo, handlePlay, handleInstall }: Props) => {
175161
{is_installed && !is.queued && (
176162
<>
177163
<button
164+
disabled={
165+
is.reparing ||
166+
is.moving ||
167+
is.updating ||
168+
is.uninstalling ||
169+
is.syncing ||
170+
is.launching ||
171+
is.installingWinetricksPackages ||
172+
is.installingRedist
173+
}
174+
autoFocus={true}
175+
onClick={async () => handlePlay(gameInfo)}
178176
className={classNames(
179177
'button',
180178
{
@@ -193,29 +191,10 @@ const MainButton = ({ gameInfo, handlePlay, handleInstall }: Props) => {
193191
},
194192
'mainBtn'
195193
)}
196-
disabled={
197-
is.reparing ||
198-
is.moving ||
199-
is.updating ||
200-
is.uninstalling ||
201-
is.syncing ||
202-
is.launching ||
203-
is.installingWinetricksPackages ||
204-
is.installingRedist
205-
}
206-
autoFocus={true}
207-
onClick={async () => handlePlay(gameInfo)}
208194
>
209195
{getPlayLabel()}
210196
</button>
211-
{showAltPlayAction() && (
212-
<button className="button altPlay is-success">
213-
<ArrowBackIosNew />
214-
<a className="button" onClick={handleAltLaunch}>
215-
{getAltPlayLabel()}
216-
</a>
217-
</button>
218-
)}
197+
{altPlayAction()}
219198
</>
220199
)}
221200
{(!is_installed || is.queued) && (

src/frontend/screens/Game/GamePage/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ export default React.memo(function GamePage(): JSX.Element | null {
262262

263263
let hasUpdate = false
264264

265-
// create setting context functions
266265
const settingsContextValues = useSettingsContext({
267266
appName,
268267
gameInfo,

0 commit comments

Comments
 (0)