@@ -8,7 +8,6 @@ import { spawn, exec } from 'child_process';
88import { getAllCoverImageUrls , getGameMetaData } from './src/js/backends.js' ;
99
1010import { PLATFORMS , getPlatformInfo } from './src/js/platforms.js' ;
11- import { pickFolderPersist } from "./src/js/portal-picker.js" ;
1211
1312import axios from 'axios' ;
1413import os from 'os' ;
@@ -275,6 +274,7 @@ function loadPreferences() {
275274 platformPreferences === null ||
276275 typeof platformPreferences . isEnabled !== 'boolean' ||
277276 typeof platformPreferences . viewMode !== 'string' ||
277+ typeof platformPreferences . gamesDir !== 'string' ||
278278 typeof platformPreferences . emulator !== 'string' ||
279279 typeof platformPreferences . emulatorArgs !== 'string' ||
280280 ! Array . isArray ( platformPreferences . extensions )
@@ -356,7 +356,6 @@ const downloadAndSaveImage = async (imgSrc, platform, gameName, gamesDir) => {
356356 }
357357} ;
358358
359-
360359// delete cover from covers directory (with existence check)
361360ipcMain . handle ( 'delete-image' , async ( _event , imagePath ) => {
362361 return new Promise ( resolve => {
@@ -489,6 +488,16 @@ ipcMain.handle('get-user-data', () => {
489488 } ;
490489} ) ;
491490
491+ ipcMain . handle ( 'select-file-or-directory' , async ( event , property ) => {
492+
493+ const result = await dialog . showOpenDialog ( { properties : [ property ] } ) ;
494+
495+ if ( ! result . canceled && result . filePaths . length > 0 ) {
496+ return result . filePaths [ 0 ] ;
497+ }
498+ return null ;
499+ } ) ;
500+
492501ipcMain . handle ( 'go-to-url' , async ( event , link ) => {
493502 console . log ( "url: " , link ) ;
494503 shell . openExternal ( link ) ;
@@ -741,6 +750,7 @@ const defaultPreferences = {
741750PLATFORMS . forEach ( ( platform , index ) => {
742751 defaultPreferences [ platform . name ] = {
743752 isEnabled : false ,
753+ gamesDir : "" ,
744754 viewMode : "grid" ,
745755 emulator : "" ,
746756 emulatorArgs : "" ,
@@ -1106,36 +1116,3 @@ ipcMain.handle('get-flatpak-download-size', async (event, appId) => {
11061116 } ) ;
11071117 } ) ;
11081118} ) ;
1109-
1110-
1111- ipcMain . handle ( 'ping' , ( ) => {
1112- console . log ( "🌍 Ping handler called - IPC is working!" ) ;
1113- return 'pong' ;
1114- } ) ;
1115-
1116- ipcMain . handle ( "select-file-or-directory" , async ( event , property ) => {
1117- console . log ( "🌍 IPC handler CALLED for:" , property ) ;
1118- const isFlatpak = ! ! process . env . FLATPAK_ID ;
1119- console . log ( "🌍 Running in Flatpak?" , isFlatpak ) ;
1120-
1121- try {
1122- // Flatpak with working portals would be ideal, but crashes with V8 sandbox
1123- // For now, just use Electron dialogs with available filesystem permissions
1124-
1125- console . log ( "🔍 Using Electron native dialog for" , property ) ;
1126- const result = await dialog . showOpenDialog ( {
1127- title : property === 'openDirectory' ? 'Choose a folder' : 'Choose a file' ,
1128- properties : [ property ] ,
1129- modal : true
1130- } ) ;
1131- console . log ( "🔄 Dialog result:" , result ) ;
1132- if ( result . canceled || result . filePaths . length === 0 ) {
1133- return null ;
1134- }
1135- return result . filePaths [ 0 ] ;
1136-
1137- } catch ( e ) {
1138- console . error ( "IPC handler error:" , e ) ;
1139- return null ;
1140- }
1141- } ) ;
0 commit comments