Skip to content

Commit

Permalink
Prevent "installation" of nonexistent builds
Browse files Browse the repository at this point in the history
It's possible to click "Install" when there are no builds to choose
from, resulting in a (seemingly common) error[0]. There are a few
interlinked issues at play here. One is that we don't have strict
null checks on, that Underscore's type signatures don't acknowledge
`undefined` as a possible return value, and that a game is
considered installable if there are no errors, and we're not
calling the API. What it doesn't consider is the possibility that
the API tells us that there's nothing available.

I've resolved this at the earliest point in the user experience, by
redefining "installability" to include the presence of an
installable build. The other issues regarding nullability are still
present, but aren't practically a concern from what I've been able
to reproduce.

[0]https://itch.io/t/1112356/cannot-read-property-build-of-undefined-error-when-trying-to-install-games
  • Loading branch information
alts committed Jan 25, 2024
1 parent 3926ecc commit 889280f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/renderer/modal-widgets/PlanInstall/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class PlanInstall extends React.PureComponent<Props, State> {
error,
} = this.state;

let canInstall = !error && !busy;
let canInstall = !error && !busy && uploads && uploads.length > 0;
let locationOptions = installLocations.map((il) => {
let val: InstallLocationOption = {
label: `${il.path} (${fileSize(il.sizeInfo.freeSize)} free)`,
Expand Down Expand Up @@ -251,6 +251,8 @@ class PlanInstall extends React.PureComponent<Props, State> {
? this.renderBusy()
: error
? this.renderError()
: uploads && uploads.length == 0
? this.renderNoBuilds()
: this.renderSizes()}
<Filler />
<ModalButtons>
Expand Down Expand Up @@ -317,6 +319,16 @@ class PlanInstall extends React.PureComponent<Props, State> {
);
}

renderNoBuilds() {
return (
<ErrorContainer>
<ErrorParagraph>
<Icon icon="error" /> {T(_("plan_install.no_available_downloads"))}
</ErrorParagraph>
</ErrorContainer>
);
}

renderSizes() {
const { info, pickedInstallLocationId, installLocations } = this.state;
if (!info) {
Expand Down
2 changes: 2 additions & 0 deletions src/static/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,7 @@
"plan_install.disk_space_required": "Disk space required",
"plan_install.disk_space_available": "Disk space available",

"plan_install.no_available_downloads": "No compatible downloads were found",

"empty_state.nothing_to_see_here": "Nothing to see here"
}

0 comments on commit 889280f

Please sign in to comment.