@ -20,43 +20,39 @@ import libcoreGetVersion from 'commands/libcoreGetVersion'
import db from 'helpers/db'
import dbMiddleware from 'middlewares/db'
import CounterValues from 'helpers/countervalues'
import hardReset from 'helpers/hardReset'
import App from 'components/App'
import 'styles/global'
if ( process . env . LEDGER_RESET_ALL ) {
db . resetAll ( )
}
// Init db with defaults if needed
db . init ( 'settings' , { } )
const history = createHistory ( )
const store = createStore ( { history , dbMiddleware } )
const rootNode = document . getElementById ( 'app' )
const settings = db . get ( 'settings' )
store . dispatch ( fetchSettings ( settings ) )
async function init ( ) {
if ( process . env . LEDGER_RESET_ALL ) {
await hardReset ( )
}
const countervaluesData = db . get ( 'countervalues' )
if ( countervaluesData ) {
store . dispatch ( CounterValues . importAction ( countervaluesData ) )
}
// Init db with defaults if needed
db . init ( 'settings' , { } )
const state = store . getState ( )
const language = getLanguage ( state )
const locked = isLocked ( state )
const history = createHistory ( )
const store = createStore ( { history , dbMiddleware } )
moment . locale ( language )
const settings = db . get ( 'settings' )
store . dispatch ( fetchSettings ( settings ) )
function r ( Comp ) {
if ( rootNode ) {
render ( < AppContainer > { Comp } < / A p p C o n t a i n e r > , r o o t N o d e )
const countervaluesData = db . get ( 'countervalues' )
if ( countervaluesData ) {
store . dispatch ( CounterValues . importAction ( countervaluesData ) )
}
}
async function init ( ) {
const state = store . getState ( )
const language = getLanguage ( state )
const locked = isLocked ( state )
moment . locale ( language )
// FIXME IMO init() really should only be for window. any other case is a hack!
const isMainWindow = remote . getCurrentWindow ( ) . name === 'MainWindow'
@ -92,6 +88,12 @@ async function init() {
}
}
function r ( Comp ) {
if ( rootNode ) {
render ( < AppContainer > { Comp } < / A p p C o n t a i n e r > , r o o t N o d e )
}
}
init ( ) . catch ( e => {
// for now we make the app crash instead of pending forever. later we can render the error OR try to recover, but probably this is unrecoverable cases.
logger . error ( e )