Skip to content

Commit

Permalink
feat: Add logs around note opening
Browse files Browse the repository at this point in the history
  This can help debugging issues when opening a note fails.
  • Loading branch information
taratatach committed Jan 7, 2025
1 parent dc96d84 commit 3e109ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
30 changes: 15 additions & 15 deletions gui/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Check failure on line 644 in gui/main.js

View workflow job for this annotation

GitHub Actions / Lint & Unit tests

Replace `"no·valid·config"` with `'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) {
Expand Down
10 changes: 5 additions & 5 deletions gui/utils/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ const openMarkdownViewer = async (
}
}

const showGenericError = (filePath, err) => {
const showGenericError = async (filePath, err) => {
log.error('Could not display markdown content of note', {
err,
path: filePath,
filePath,
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')]
})
}
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 3e109ab

Please sign in to comment.