diff --git a/gui/main.js b/gui/main.js index 47f4abcf9..180a25dea 100644 --- a/gui/main.js +++ b/gui/main.js @@ -522,11 +522,12 @@ app.on('second-instance', async (event, argv) => { log.info('second instance invoked with arguments', { filePath }) // If we found a note to open, stop here. Otherwise, show main window. - if ( - filePath.endsWith('.cozy-note') && - (await openNote(filePath, { desktop })) - ) + if (filePath.endsWith('.cozy-note')) { + await openNote(filePath, { desktop }) return + } else { + log.warn('file path argument does not have valid Cozy note extension') + } } // Make sure the main window exists before trying to show it @@ -633,19 +634,18 @@ app.on('ready', async () => { // We need a valid config to start the App and open the requested note. // We assume users won't have notes they want to open without a connected // client. - if (!desktop.config.syncPath) { - await exit(0) - return + if (desktop.config.syncPath) { + if (filePath.endsWith('.cozy-note')) { + await openNote(filePath, { desktop }) + } else { + log.warn('file path argument does not have valid Cozy note extension') + } + } else { + log.warn("no valid config") } - // If we found a note to open, stop here. Otherwise, start sync app. - if ( - filePath.endsWith('.cozy-note') && - (await openNote(filePath, { desktop })) - ) { - await exit(0) - return - } + await exit(0) + return } if (shouldStartSync) { diff --git a/gui/utils/notes.js b/gui/utils/notes.js index 77b2ceb2b..b4871f075 100644 --- a/gui/utils/notes.js +++ b/gui/utils/notes.js @@ -47,7 +47,7 @@ const openMarkdownViewer = async ( } } -const showGenericError = (filePath, err) => { +const showGenericError = async (filePath, err) => { log.error('Could not display markdown content of note', { err, path: filePath, @@ -55,10 +55,10 @@ const showGenericError = (filePath, err) => { sentry: true }) - dialog.showMessageBoxSync(null, { + await dialog.showMessageBox(null, { type: 'error', message: translate('Error Unexpected error'), - details: `${err.name}: ${err.message}`, + detail: `${err.name}: ${err.message}`, buttons: [translate('AppMenu Close')] }) } @@ -119,11 +119,11 @@ const openNote = async ( ) return true } catch (err) { - showGenericError(filePath, err) + await showGenericError(filePath, err) return false } } else { - showGenericError(filePath, err) + await showGenericError(filePath, err) return false } }