Skip to content

Fix some issues when uninstalling games #1950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/backend/api/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export const uninstall = async (
const [appName, shouldRemovePrefix, runner] = args
if (runner === 'sideload') {
return ipcRenderer.invoke('removeApp', { appName, shouldRemovePrefix })
} else {
return ipcRenderer.invoke('uninstall', args)
}
ipcRenderer.invoke('uninstall', args)
}
export const repair = async (appName: string, runner: Runner) =>
ipcRenderer.invoke('repair', appName, runner)
Expand Down
37 changes: 27 additions & 10 deletions src/frontend/screens/Game/GamePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default function GamePage(): JSX.Element | null {
const isQueued = status === 'queued'
const isReparing = status === 'repairing'
const isMoving = status === 'moving'
const isUninstalling = status === 'uninstalling'

const backRoute = location.state?.fromDM ? '/download-manager' : '/'

Expand Down Expand Up @@ -390,6 +391,16 @@ export default function GamePage(): JSX.Element | null {
</div>
<TimeContainer game={appName} />
<div className="gameStatus">
{isUninstalling && (
<p
style={{
color: 'var(--danger)',
fontStyle: 'italic'
}}
>
{t('status.uninstalling', 'Uninstalling')}
</p>
)}
{isInstalling ||
(isUpdating && (
<progress
Expand Down Expand Up @@ -427,15 +438,15 @@ export default function GamePage(): JSX.Element | null {
<Anticheat gameInfo={gameInfo} />
<div className="buttonsWrapper">
{is_installed && (
<>
<button
disabled={isReparing || isMoving || isUpdating}
onClick={handlePlay()}
className={`button ${getPlayBtnClass()}`}
>
{getPlayLabel()}
</button>
</>
<button
disabled={
isReparing || isMoving || isUpdating || isUninstalling
}
onClick={handlePlay()}
className={`button ${getPlayBtnClass()}`}
>
{getPlayLabel()}
</button>
)}
{is_installed ? (
<Link
Expand All @@ -454,7 +465,13 @@ export default function GamePage(): JSX.Element | null {
) : (
<button
onClick={async () => handleInstall(is_installed)}
disabled={isPlaying || isUpdating || isReparing || isMoving}
disabled={
isPlaying ||
isUpdating ||
isReparing ||
isMoving ||
isUninstalling
}
className={`button ${getButtonClass(is_installed)}`}
>
{`${getButtonLabel(is_installed)}`}
Expand Down
20 changes: 18 additions & 2 deletions src/frontend/screens/Library/components/GameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,14 @@ const GameCard = ({
const isMoving = status === 'moving'
const isPlaying = status === 'playing'
const isQueued = status === 'queued'
const isUninstalling = status === 'uninstalling'
const haveStatus =
isMoving || isReparing || isInstalling || isUpdating || isQueued
isMoving ||
isReparing ||
isInstalling ||
isUpdating ||
isQueued ||
isUninstalling

const { percent = '' } = progress
const installingGrayscale = isInstalling
Expand Down Expand Up @@ -127,6 +133,9 @@ const GameCard = ({
}

function getStatus() {
if (isUninstalling) {
return t('status.uninstalling', 'Uninstalling')
}
if (isUpdating) {
return t('status.updating') + ` ${percent}%`
}
Expand Down Expand Up @@ -155,6 +164,13 @@ const GameCard = ({
}

const renderIcon = () => {
if (isUninstalling) {
return (
<button className="svg-button iconDisabled">
<svg />
</button>
)
}
if (isQueued) {
return (
<SvgButton
Expand Down Expand Up @@ -366,7 +382,7 @@ const GameCard = ({
<FontAwesomeIcon size={'2x'} icon={faRepeat} />
</SvgButton>
)}
{isInstalled && (
{isInstalled && !isUninstalling && (
<>
<SvgButton
title={`${t('submenu.settings')} (${title})`}
Expand Down