Skip to content

Commit

Permalink
fix: handle missing local Electron.app
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jan 13, 2024
1 parent 42630d5 commit ef54ccf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/renderer/components/commands-runner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { Button, ButtonProps, Spinner } from '@blueprintjs/core';
import { observer } from 'mobx-react';

import { InstallState } from '../../interfaces';
import { InstallState, VersionSource } from '../../interfaces';
import { AppState } from '../state';

interface RunnerProps {
Expand All @@ -29,7 +29,7 @@ export const Runner = observer(
isOnline,
} = this.props.appState;

const state = currentElectronVersion?.state;
const { downloadProgress, source, state } = currentElectronVersion;
const props: ButtonProps = { disabled: true };

if ([downloading, missing].includes(state) && !isOnline) {
Expand All @@ -41,12 +41,7 @@ export const Runner = observer(
switch (state) {
case downloading: {
props.text = 'Downloading';
props.icon = (
<Spinner
size={16}
value={currentElectronVersion?.downloadProgress}
/>
);
props.icon = <Spinner size={16} value={downloadProgress} />;
break;
}
case installing: {
Expand All @@ -72,6 +67,13 @@ export const Runner = observer(
}
break;
}
case missing: {
if (source === VersionSource.local) {
props.text = 'Unavailable';
props.icon = 'issue';
break;
}
}
default: {
props.text = 'Checking status';
props.icon = <Spinner size={16} />;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/version-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function getItemLabel({ source, state, name }: RunnableVersion): string {
export function getItemIcon({ source, state }: RunnableVersion): IconName {
// If a version is local, either it's there or it's not.
if (source === VersionSource.local) {
return state === InstallState.missing ? 'disable' : 'saved';
return state === InstallState.missing ? 'issue' : 'saved';
}

const installStateIcons: Record<InstallState, IconName> = {
Expand Down

0 comments on commit ef54ccf

Please sign in to comment.