fix(ui): show installing for downloaded games

The redesigned action hook marked every accepted install command as Checking
Peers. That is correct while the launcher is asking peers for file details, but
it is wrong for a game that is already downloaded and only needs local archive
installation.

Track the already-downloaded path separately and optimistically show Installing
until the backend install lifecycle event arrives. Peer-backed downloads keep the
existing Checking Peers state.

Test Plan:
- git diff --check

Refs: user redesign nitpick about install button state
This commit is contained in:
2026-05-19 20:49:22 +02:00
parent 50698f9a7d
commit 74d9266723
2 changed files with 22 additions and 4 deletions
@@ -52,6 +52,7 @@ export interface UseGamesResult {
totalPeerCount: number;
requestGames: () => Promise<void>;
markChecking: (id: string) => void;
markInstalling: (id: string) => void;
cancelChecking: (id: string) => void;
}
@@ -95,6 +96,15 @@ export const useGames = (rescanGameDir: () => void): UseGamesResult => {
}, CHECKING_PEERS_TIMEOUT_MS);
}, [cancelChecking]);
const markInstalling = useCallback((id: string) => {
cancelChecking(id);
setGames(prev => prev.map(item =>
item.id === id
? applyPatch(item, { install_status: InstallStatus.Installing, clearStatus: true })
: item,
));
}, [cancelChecking]);
const requestGames = useCallback(async () => {
try {
await invoke('request_games');
@@ -247,6 +257,7 @@ export const useGames = (rescanGameDir: () => void): UseGamesResult => {
totalPeerCount,
requestGames,
markChecking,
markInstalling,
cancelChecking,
};
};