lbry-desktop/ui/js/main.js

44 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-11-22 21:19:08 +01:00
import React from 'react';
import ReactDOM from 'react-dom';
import lbry from './lbry.js';
2017-03-31 01:00:33 +02:00
import lbryio from './lbryio.js';
import lighthouse from './lighthouse.js';
2016-11-22 21:19:08 +01:00
import App from './app.js';
import SplashScreen from './component/splash.js';
2017-04-10 14:32:40 +02:00
import SnackBar from './component/snack-bar.js';
2017-04-09 17:06:23 +02:00
import {AuthOverlay} from './component/auth.js';
2016-11-22 21:19:08 +01:00
const {remote} = require('electron');
const contextMenu = remote.require('./menu/context-menu');
lbry.showMenuIfNeeded();
2016-11-22 21:19:08 +01:00
window.addEventListener('contextmenu', (event) => {
contextMenu.showContextMenu(remote.getCurrentWindow(), event.x, event.y,
lbry.getClientSetting('showDeveloperMenu'));
event.preventDefault();
});
2017-03-31 01:00:33 +02:00
let init = function() {
2017-01-05 23:30:36 +01:00
window.lbry = lbry;
window.lighthouse = lighthouse;
2017-04-09 17:06:23 +02:00
let canvas = document.getElementById('canvas');
2017-04-09 17:06:23 +02: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 14:32:40 +02:00
function onDaemonReady() {
2017-04-09 17:06:23 +02:00
window.sessionStorage.setItem('loaded', 'y'); //once we've made it here once per session, we don't need to show splash again
2017-04-10 14:32:40 +02:00
ReactDOM.render(<div><AuthOverlay /><App /><SnackBar /></div>, canvas)
2017-04-09 17:06:23 +02:00
}
2017-04-10 14:32:40 +02:00
if (window.sessionStorage.getItem('loaded') == 'y') {
2017-04-09 17:06:23 +02:00
onDaemonReady();
} else {
2017-04-09 17:06:23 +02:00
ReactDOM.render(<SplashScreen message="Connecting" onLoadDone={onDaemonReady} />, canvas);
}
2016-03-14 23:05:24 +01:00
};
init();