Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 14 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"stage": 0,
"presets": [
"react",
"es2015",
"stage-0"
],
"plugins": [
"transform-react-display-name",
"transform-decorators-legacy"
],
"env": {
"production": {
"optional": [
"utility.inlineEnvironmentVariables",
"optimisation"
"plugins": [
"transform-inline-environment-variables"
]
},
"development": {
"plugins": [
"react-transform"
],
"extra": {
"react-transform": {
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
Expand All @@ -21,8 +25,8 @@
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}
}
}]
]
}
}
}
2 changes: 1 addition & 1 deletion app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs'
const app = require('app')

const isProduction = process.env.NODE_ENV === 'production'
const IPFS_PATH_FILE = app.getDataPath() + '/ipfs-electron-app-node-path'
const IPFS_PATH_FILE = path.join(app.getPath('appData'), '4ipfs-electron-app-node-path')

const trayIcon = () => {
if (os.platform() !== 'darwin') {
Expand Down
2 changes: 1 addition & 1 deletion app/controls/open-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function openConsole () {
}

const consoleWindow = new BrowserWindow(config.window)
consoleWindow.loadUrl(apiAddrToUrl(res.Value))
consoleWindow.loadURL(apiAddrToUrl(res.Value))
})
} else {
// TODO() error should be emited to a error panel
Expand Down
2 changes: 1 addition & 1 deletion app/controls/open-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const BrowserWindow = require('browser-window')
function openSettings () {
const settingsWindow = new BrowserWindow(config.window)

settingsWindow.loadUrl(config.urls.settings)
settingsWindow.loadURL(config.urls.settings)

settingsWindow.webContents.on('did-finish-load', () => {})
}
Expand Down
34 changes: 19 additions & 15 deletions app/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import menubar from 'menubar'
import fs from 'fs'
import ipfsd from 'ipfsd-ctl'
import {join} from 'path'
import {lookupPretty} from 'ipfs-geoip'
// import {lookupPretty} from 'ipfs-geoip'

import config from './config'
import dragDrop from './controls/drag-drop'
Expand All @@ -13,6 +13,7 @@ const BrowserWindow = require('browser-window')
if (config.isProduction) {
require('crash-reporter').start()
} else {
require('longjohn')
require('electron-debug')()
}

Expand All @@ -36,11 +37,11 @@ function pollStats (ipfs) {
ipfs.id((err, peer) => {
if (err) throw err

lookupPretty(ipfs, peer.Addresses, (err, location) => {
if (err) throw err
statsCache.location = location && location.formatted
ipc.send('stats', statsCache)
})
// lookupPretty(ipfs, peer.Addresses, (err, location) => {
// if (err) throw err
// statsCache.location = location && location.formatted
// ipc.send('stats', statsCache)
// })
})
}

Expand Down Expand Up @@ -140,7 +141,7 @@ function initialize (path, node) {

const welcomeWindow = new BrowserWindow(config.window)

welcomeWindow.loadUrl(config.urls.welcome)
welcomeWindow.loadURL(config.urls.welcome)
welcomeWindow.webContents.on('did-finish-load', () => {
ipc.send('setup-config-path', path)
})
Expand Down Expand Up @@ -196,6 +197,14 @@ function initialize (path, node) {
})
}

function reboot () {
logger.error('Trying to start a second instance')
dialog.showErrorBox(
'Multiple instances',
'Sorry, but there can be only one instance of Station running at the same time.'
)
}

export function getIPFS () {
return IPFS
}
Expand All @@ -211,6 +220,9 @@ export function boot (lokker) {

mb = menubar(config.menuBar)

// Ensure single instance
mb.app.makeSingleInstance(reboot)

mb.on('ready', () => {
logger.info('Application is ready')

Expand Down Expand Up @@ -238,11 +250,3 @@ export function boot (lokker) {
})
})
}

export function reboot () {
logger.error('Trying to start a second instance')
dialog.showErrorBox(
'Multiple instances',
'Sorry, but there can be only one instance of Station running at the same time.'
)
}
25 changes: 8 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var mono = require('monogamous')
var winston = require('winston')
var path = require('path')
var init = require('./build/init')
'use strict'

const winston = require('winston')
const path = require('path')
const init = require('./build/init')

// Setup Logging
var logger = new (winston.Logger)({
const logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
handleExceptions: false
Expand All @@ -16,20 +17,10 @@ var logger = new (winston.Logger)({
]
})

process.on('uncaughtException', function (error) {
process.on('uncaughtException', error => {
const msg = error.message || error
logger.error(`Uncaught Exception: ${msg}`, error, error.stack, arguments)
process.exit(1)
})

// This ensures that there is only one instance of our application.
var booter = mono({sock: 'station'}, {})

booter.on('boot', init.boot.bind(init, logger))
booter.on('reboot', init.reboot.bind(init))
booter.on('error', function (err) {
logger.error(err)
})

logger.info('Booting')
booter.boot()
init.boot(logger)
Loading