fixed function arguments

This commit is contained in:
discollizard 2024-06-22 13:19:35 -03:00
parent d4aebf7d99
commit ea412c64c3
3 changed files with 19 additions and 11 deletions

View File

@ -131,9 +131,11 @@ export function GameDetailsContextProvider({
return window.electron.getDefaultDownloadsPath();
};
const selectGameExecutable = async (gameInstallerFolderIfExists: string | null) => {
const downloadsPath = gameInstallerFolderIfExists ?? await getDownloadsPath();
const selectGameExecutable = async (
gameInstallerFolderIfExists?: string
) => {
const downloadsPath =
gameInstallerFolderIfExists ?? (await getDownloadsPath());
return window.electron
.showOpenDialog({

View File

@ -13,7 +13,9 @@ export interface GameDetailsContext {
showRepacksModal: boolean;
showGameOptionsModal: boolean;
setGameColor: React.Dispatch<React.SetStateAction<string>>;
selectGameExecutable: (gameInstallerFolderIfExists: string | null) => Promise<string | null>;
selectGameExecutable: (
gameInstallerFolderIfExists?: string
) => Promise<string | null>;
updateGame: () => Promise<void>;
setShowRepacksModal: React.Dispatch<React.SetStateAction<boolean>>;
setShowGameOptionsModal: React.Dispatch<React.SetStateAction<boolean>>;

View File

@ -53,21 +53,25 @@ export function HeroPanelActions() {
return;
}
let gameInstallerFolderIfExists: string | null = null
let gameInstallerFolderIfExists
if (game && game.folderName){
if (game && game.folderName) {
let downloadsPath = await window.electron.getDefaultDownloadsPath();
if (userPreferences?.downloadsPath)
downloadsPath = userPreferences.downloadsPath;
const folderSeparator = window.electron.platform == 'win32'
? '\\'
: '/'
const folderSeparator =
window.electron.platform == "win32" ? "\\" : "/";
gameInstallerFolderIfExists = (game.downloadPath ?? downloadsPath)+folderSeparator+game.folderName!
gameInstallerFolderIfExists =
(game.downloadPath ?? downloadsPath) +
folderSeparator +
game.folderName!;
}
const gameExecutablePath = await selectGameExecutable(gameInstallerFolderIfExists);
const gameExecutablePath = await selectGameExecutable(
gameInstallerFolderIfExists
);
if (gameExecutablePath)
window.electron.openGame(game.id, gameExecutablePath);
}