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';
|
2016-12-29 10:41:28 +01:00
|
|
|
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-03-17 12:41:01 +01:00
|
|
|
const {remote} = require('electron');
|
|
|
|
const contextMenu = remote.require('./menu/context-menu');
|
|
|
|
|
2017-03-08 09:56:34 +01:00
|
|
|
lbry.showMenuIfNeeded();
|
2016-11-22 21:19:08 +01:00
|
|
|
|
2017-03-17 12:41:01 +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;
|
2017-03-08 07:23:07 +01:00
|
|
|
window.lighthouse = lighthouse;
|
2016-12-29 10:41:28 +01:00
|
|
|
|
2016-03-14 23:05:24 +01:00
|
|
|
var canvas = document.getElementById('canvas');
|
2017-01-25 04:20:41 +01:00
|
|
|
if (window.sessionStorage.getItem('loaded') == 'y') {
|
|
|
|
ReactDOM.render(<App/>, canvas)
|
|
|
|
} else {
|
|
|
|
ReactDOM.render(
|
2017-03-30 21:05:31 +02:00
|
|
|
(
|
|
|
|
<SplashScreen message="Connecting" onLoadDone={function() {
|
2017-03-31 01:00:33 +02:00
|
|
|
// There are a couple of conditions where we want to preempt loading the app and send the user to a
|
|
|
|
// different page. TODO: Find a better place for this logic.
|
|
|
|
|
|
|
|
if (!localStorage.getItem('claimCodeDone') && ['', '?', 'discover'].includes(window.location.search)) {
|
2017-01-25 04:20:41 +01:00
|
|
|
lbry.getBalance((balance) => {
|
|
|
|
if (balance <= 0) {
|
2017-03-30 21:05:31 +02:00
|
|
|
window.location.href = '?claim';
|
2017-01-25 04:20:41 +01:00
|
|
|
} else {
|
2017-03-30 21:05:31 +02:00
|
|
|
ReactDOM.render(<App/>, canvas);
|
2017-01-25 04:20:41 +01:00
|
|
|
}
|
|
|
|
});
|
2017-03-30 21:05:31 +02:00
|
|
|
} else {
|
2016-07-04 17:29:58 +02:00
|
|
|
ReactDOM.render(<App/>, canvas);
|
2017-03-30 21:05:31 +02:00
|
|
|
}
|
|
|
|
}}/>
|
2017-03-31 01:00:33 +02:00
|
|
|
), canvas);
|
2017-01-25 04:20:41 +01:00
|
|
|
}
|
2016-03-14 23:05:24 +01:00
|
|
|
};
|
|
|
|
|
2017-04-01 08:36:45 +02:00
|
|
|
init();
|