Skip to content

Commit aa9c468

Browse files
committed
fix loading single file
1 parent 6778eb6 commit aa9c468

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

packages/app/src/main/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,31 @@ function createWindow(): void {
168168
function registerIpcHandlers(): void {
169169
// --- dialog:openFile ---------------------------------------------------
170170
ipcMain.handle('dialog:openFile', async () => {
171-
const result = await dialog.showOpenDialog({
172-
properties: ['openFile', 'openDirectory'],
171+
// Try file selection first; on Linux GTK, combining openFile +
172+
// openDirectory forces directory-only mode, so we try file first
173+
// and fall back to directory picker if the user cancels.
174+
const fileResult = await dialog.showOpenDialog({
175+
title: 'Open Location File or Folder',
176+
properties: ['openFile'],
173177
filters: [
174178
{ name: 'JSON files', extensions: ['json'] },
175179
{ name: 'All files', extensions: ['*'] },
176180
],
177181
});
178-
if (result.canceled || result.filePaths.length === 0) return null;
179-
return result.filePaths[0];
182+
if (!fileResult.canceled && fileResult.filePaths.length > 0) {
183+
return fileResult.filePaths[0];
184+
}
185+
186+
// User cancelled — offer directory picker as second chance
187+
const dirResult = await dialog.showOpenDialog({
188+
title: 'Open Takeout Folder',
189+
properties: ['openDirectory'],
190+
});
191+
if (!dirResult.canceled && dirResult.filePaths.length > 0) {
192+
return dirResult.filePaths[0];
193+
}
194+
195+
return null;
180196
});
181197

182198
// --- dialog:saveFile ---------------------------------------------------

0 commit comments

Comments
 (0)