wip
This commit is contained in:
@@ -29,6 +29,7 @@ interface Game {
|
||||
description: string;
|
||||
size: number;
|
||||
thumbnail: Uint8Array | number[];
|
||||
downloaded: boolean;
|
||||
installed: boolean;
|
||||
install_status: InstallStatus;
|
||||
eti_game_version?: string;
|
||||
@@ -49,7 +50,7 @@ const App = () => {
|
||||
switch (filter) {
|
||||
case 'available':
|
||||
// Show union of installed games and games with peers
|
||||
return games.filter(game => game.installed || game.peer_count > 0);
|
||||
return games.filter(game => game.installed || game.downloaded || game.peer_count > 0);
|
||||
case 'installed':
|
||||
return games.filter(game => game.installed);
|
||||
case 'all':
|
||||
@@ -381,6 +382,36 @@ const App = () => {
|
||||
return false;
|
||||
};
|
||||
|
||||
const getInProgressLabel = (game: Game): string | undefined => {
|
||||
switch (game.install_status) {
|
||||
case InstallStatus.CheckingPeers:
|
||||
return 'Checking peers...';
|
||||
case InstallStatus.Downloading:
|
||||
return 'Downloading...';
|
||||
case InstallStatus.Unpacking:
|
||||
return 'Unpacking...';
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const getActionLabel = (game: Game): string => {
|
||||
const inProgress = getInProgressLabel(game);
|
||||
if (inProgress) {
|
||||
return inProgress;
|
||||
}
|
||||
|
||||
if (!game.installed) {
|
||||
return game.downloaded ? 'Install' : 'Download';
|
||||
}
|
||||
|
||||
if (needsUpdate(game)) {
|
||||
return 'Update';
|
||||
}
|
||||
|
||||
return 'Play';
|
||||
};
|
||||
|
||||
const dialogGameDir = async () => {
|
||||
const file = await open({
|
||||
multiple: false,
|
||||
@@ -484,21 +515,11 @@ const App = () => {
|
||||
runGame(item.id);
|
||||
}
|
||||
}}>
|
||||
{!item.installed
|
||||
? item.install_status === InstallStatus.CheckingPeers ? 'Checking peers...'
|
||||
: item.install_status === InstallStatus.Downloading ? 'Downloading...'
|
||||
: item.install_status === InstallStatus.Unpacking ? 'Unpacking...'
|
||||
: 'Install'
|
||||
: needsUpdate(item)
|
||||
? item.install_status === InstallStatus.CheckingPeers ? 'Checking peers...'
|
||||
: item.install_status === InstallStatus.Downloading ? 'Downloading...'
|
||||
: item.install_status === InstallStatus.Unpacking ? 'Unpacking...'
|
||||
: 'Update'
|
||||
: 'Play'}
|
||||
{getActionLabel(item)}
|
||||
</div>
|
||||
<div className={`item-info${item.status_level ? ` ${item.status_level}` : ''}`}>
|
||||
<div className="status-left">
|
||||
{item.status_message && item.peer_count === 0 && !item.installed ? item.status_message : ''}
|
||||
{item.status_message && item.peer_count === 0 && !item.installed && !item.downloaded ? item.status_message : ''}
|
||||
</div>
|
||||
<div className="status-right">
|
||||
{item.peer_count > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user