2016-11-22 14:19:08 -06:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import lbry from './lbry.js';
|
2017-03-30 19:00:33 -04:00
|
|
|
import lbryio from './lbryio.js';
|
2016-12-29 04:41:28 -05:00
|
|
|
import lighthouse from './lighthouse.js';
|
2017-04-07 12:15:22 +07:00
|
|
|
import App from './component/app/index.js';
|
2016-11-22 14:19:08 -06:00
|
|
|
import SplashScreen from './component/splash.js';
|
2017-04-10 08:32:40 -04:00
|
|
|
import SnackBar from './component/snack-bar.js';
|
2017-04-09 11:06:23 -04:00
|
|
|
import {AuthOverlay} from './component/auth.js';
|
2017-04-07 12:15:22 +07:00
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import store from 'store.js';
|
2017-04-22 20:17:01 +07:00
|
|
|
import { runTriggers } from 'triggers'
|
2017-04-22 20:46:04 +07:00
|
|
|
import {
|
|
|
|
doDaemonReady
|
|
|
|
} from 'actions/app'
|
2016-11-22 14:19:08 -06:00
|
|
|
|
2017-03-17 07:41:01 -04:00
|
|
|
const {remote} = require('electron');
|
|
|
|
const contextMenu = remote.require('./menu/context-menu');
|
2017-04-07 12:15:22 +07:00
|
|
|
const app = require('./app')
|
2017-03-17 07:41:01 -04:00
|
|
|
|
2017-03-08 03:56:34 -05:00
|
|
|
lbry.showMenuIfNeeded();
|
2016-11-22 14:19:08 -06:00
|
|
|
|
2017-03-17 07:41:01 -04:00
|
|
|
window.addEventListener('contextmenu', (event) => {
|
|
|
|
contextMenu.showContextMenu(remote.getCurrentWindow(), event.x, event.y,
|
|
|
|
lbry.getClientSetting('showDeveloperMenu'));
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
|
2017-04-07 12:15:22 +07:00
|
|
|
const initialState = app.store.getState();
|
2017-04-22 20:17:01 +07:00
|
|
|
app.store.subscribe(runTriggers);
|
|
|
|
runTriggers();
|
2017-04-07 12:15:22 +07:00
|
|
|
|
|
|
|
var init = function() {
|
2017-01-05 17:30:36 -05:00
|
|
|
window.lbry = lbry;
|
2017-03-08 01:23:07 -05:00
|
|
|
window.lighthouse = lighthouse;
|
2017-04-09 11:06:23 -04:00
|
|
|
let canvas = document.getElementById('canvas');
|
2016-12-29 04:41:28 -05:00
|
|
|
|
2017-04-09 11:06:23 -04:00
|
|
|
lbry.connect().then(function(isConnected) {
|
|
|
|
lbryio.authenticate() //start auth process as soon as soon as we can get an install ID
|
|
|
|
})
|
|
|
|
|
2017-04-10 08:32:40 -04:00
|
|
|
function onDaemonReady() {
|
2017-04-22 20:46:04 +07:00
|
|
|
app.store.dispatch(doDaemonReady())
|
2017-04-22 20:17:01 +07:00
|
|
|
ReactDOM.render(<Provider store={store}><div>{ lbryio.enabled ? <AuthOverlay/> : '' }<App /><SnackBar /></div></Provider>, canvas)
|
2017-04-09 11:06:23 -04:00
|
|
|
}
|
|
|
|
|
2017-04-10 08:32:40 -04:00
|
|
|
if (window.sessionStorage.getItem('loaded') == 'y') {
|
2017-04-09 11:06:23 -04:00
|
|
|
onDaemonReady();
|
2017-01-24 22:20:41 -05:00
|
|
|
} else {
|
2017-04-09 11:06:23 -04:00
|
|
|
ReactDOM.render(<SplashScreen message="Connecting" onLoadDone={onDaemonReady} />, canvas);
|
2017-01-24 22:20:41 -05:00
|
|
|
}
|
2016-03-14 18:05:24 -04:00
|
|
|
};
|
|
|
|
|
2017-04-01 02:36:45 -04:00
|
|
|
init();
|