Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, dialog } from 'electron'
import { app, dialog, shell } from 'electron'
import { join } from 'path'
import { store, createDaemon } from './utils'
import startupMenubar from './menubar'
Expand All @@ -12,7 +12,30 @@ if (!app.requestSingleInstanceLock()) {
)

// No windows were opened at this time so we don't need to do app.quit()
process.exit(0)
process.exit(1)
}

function handleError (e) {
dialog.showMessageBox({
type: 'error',
title: 'Something wrong happened',
Comment thread
hacdias marked this conversation as resolved.
Outdated
message: e.stack + '\nPlease choose one of the options bellow. All of them will copy the error message to the clipboard.',
buttons: [
'Close',
'Open logs',
'Create a new issue'

@lidel lidel Nov 19, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label could be more inviting and explicit on what will happen on click:

Suggested change
'Create a new issue'
'Help us fixing it by creating a new issue with error details'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only regards I have here is that it is the name of a button. We are lucky they're big on Windows, but I have no clue how they'll look around the other OSes.

@lidel lidel Nov 20, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I tested how it looks on Linux:
2018-11-20--16-25-51
Not the prettiest, but also not the end of the world:
2018-11-20--16-26-42
Perhaps something like Report this issue to (IPFS) developers is a good compromise?
2018-11-20--16-30-54

]
}, option => {
if (option === 1) {
const path = app.getPath('userData')
shell.openItem(path)
} else if (option === 2) {
let text = 'Please describe what you were doing when this error happened.\n\n```\n' + e.stack + '\n```'
Comment thread
hacdias marked this conversation as resolved.
Outdated
shell.openExternal('https://github.com/ipfs-shipyard/ipfs-desktop/issues/new?body=' + encodeURI(text))
}

process.exit(1)
})
}

async function setupConnection () {
Expand All @@ -31,21 +54,30 @@ async function setupConnection () {
}

async function run () {
await app.whenReady()

// Initial context object
let ctx = {
ipfsd: await setupConnection()
try {
await app.whenReady()
} catch (e) {
dialog.showErrorBox('Electron could not start', e.stack)
process.exit(1)
}

// Initialize windows. These can add properties to context
await startupMenubar(ctx)
try {
// Initial context object
let ctx = {
ipfsd: await setupConnection()
}

// Initialize windows. These can add properties to context
await startupMenubar(ctx)

// Register hooks
await registerHooks(ctx)
// Register hooks
await registerHooks(ctx)

if (!store.get('seenWelcome')) {
// TODO: open WebUI on Welcome screen
if (!store.get('seenWelcome')) {
// TODO: open WebUI on Welcome screen
}
} catch (e) {
handleError(e)
}
}

Expand Down