Skip to content

Commit dd164e6

Browse files
authored
[Library] Disable Play button while launching game (#2120)
* Disable play button while launching game * Refactor
1 parent 5c20525 commit dd164e6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/frontend/screens/Library/components/GameCard/index.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@
329329
font-size: 40px;
330330
}
331331

332-
.iconDisabled circle {
332+
.iconDisabled circle,
333+
.svg-button[disabled] circle {
333334
fill: var(--icon-disabled);
334335
}
335336

src/frontend/screens/Library/components/GameCard/index.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ const GameCard = ({
6565
const [gameAvailable, setGameAvailable] = useState(
6666
gameInfoFromProps.is_installed
6767
)
68+
const [isLaunching, setIsLaunching] = useState(false)
6869

6970
const { t } = useTranslation('gamepage')
7071
const { t: t2 } = useTranslation()
@@ -93,6 +94,18 @@ const GameCard = ({
9394
thirdPartyManagedApp
9495
} = gameInfo
9596

97+
// if the game supports cloud saves, check the config
98+
const [autoSyncSaves, setAutoSyncSaves] = useState(hasCloudSave)
99+
useEffect(() => {
100+
const checkGameConfig = async () => {
101+
const settings = await window.api.requestGameSettings(appName)
102+
setAutoSyncSaves(settings.autoSyncSaves)
103+
}
104+
if (hasCloudSave) {
105+
checkGameConfig()
106+
}
107+
}, [appName])
108+
96109
const [progress, previousProgress] = hasProgress(appName)
97110

98111
const { status, folder } =
@@ -112,6 +125,7 @@ const GameCard = ({
112125
}, [appName, status, gameInfo])
113126

114127
useEffect(() => {
128+
setIsLaunching(false)
115129
const updateGameInfo = async () => {
116130
const newInfo = await getGameInfo(appName, runner)
117131
if (newInfo) {
@@ -262,6 +276,7 @@ const GameCard = ({
262276
className={gameAvailable ? 'playIcon' : 'cancelIcon'}
263277
onClick={async () => handlePlay(runner)}
264278
title={`${t('label.playing.start')} (${title})`}
279+
disabled={isLaunching}
265280
>
266281
<PlayIcon />
267282
</SvgButton>
@@ -537,12 +552,13 @@ const GameCard = ({
537552
}
538553

539554
if (isInstalled) {
555+
setIsLaunching(true)
540556
return launch({
541557
appName,
542558
t,
543559
runner,
544560
hasUpdate,
545-
syncCloud: gameInfo?.cloud_save_enabled,
561+
syncCloud: autoSyncSaves,
546562
showDialogModal
547563
})
548564
}

0 commit comments

Comments
 (0)