mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
Fix double-click file opening with did-finish-load event
- Added did-finish-load event listener to ensure window is fully loaded - Added 500ms delay to allow TabManager initialization - Improved openFileFromPath function with better logging - Fixed race condition where files opened via double-click weren't rendering Fixes #file-association-rendering-issue 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
+20
-8
@@ -83,7 +83,18 @@ function createWindow() {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
// Handle pending file from file association will be handled by renderer-ready event
|
||||
// Wait for the page to fully load before sending file data
|
||||
mainWindow.webContents.on('did-finish-load', () => {
|
||||
console.log('Window finished loading');
|
||||
// Give renderer a moment to initialize
|
||||
setTimeout(() => {
|
||||
if (app.pendingFile && !rendererReady) {
|
||||
console.log('Opening pending file after did-finish-load:', app.pendingFile);
|
||||
openFileFromPath(app.pendingFile);
|
||||
app.pendingFile = null;
|
||||
}
|
||||
}, 500); // Wait 500ms for TabManager to initialize
|
||||
});
|
||||
}
|
||||
|
||||
function buildRecentFilesMenu() {
|
||||
@@ -1552,14 +1563,15 @@ function openFileFromPath(filePath) {
|
||||
currentFile = filePath;
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
if (mainWindow && mainWindow.webContents) {
|
||||
// Wait for the renderer to be ready (TabManager initialized) before sending file data
|
||||
if (rendererReady) {
|
||||
mainWindow.webContents.send('file-opened', { path: filePath, content });
|
||||
} else {
|
||||
// Store file to open after renderer is ready
|
||||
app.pendingFile = filePath;
|
||||
}
|
||||
console.log('Attempting to open file:', filePath, 'rendererReady:', rendererReady);
|
||||
// Always try to send, the renderer will handle it when ready
|
||||
mainWindow.webContents.send('file-opened', { path: filePath, content });
|
||||
} else {
|
||||
// Store file to open after window is created
|
||||
app.pendingFile = filePath;
|
||||
}
|
||||
} else {
|
||||
console.error('File does not exist:', filePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user