2017-08-24 15:50:14 +02:00
|
|
|
import "babel-polyfill";
|
2017-08-07 00:23:54 +02:00
|
|
|
import React from 'react';
|
2017-08-25 03:46:55 +02:00
|
|
|
import ReactDOM from 'react-dom';
|
2017-08-20 17:57:57 +02:00
|
|
|
import { Provider } from 'react-redux';
|
2017-08-24 14:30:22 +02:00
|
|
|
import { ConnectedRouter } from 'react-router-redux';
|
2017-12-30 19:06:59 +01:00
|
|
|
import query from 'query-string';
|
2017-08-25 03:46:55 +02:00
|
|
|
import 'preact/devtools';
|
2017-08-26 01:41:34 +02:00
|
|
|
import './polyfills';
|
2017-08-20 17:57:57 +02:00
|
|
|
|
2017-09-08 06:55:47 +02:00
|
|
|
import store, { create, history } from './store';
|
2017-08-22 21:49:48 +02:00
|
|
|
import scss from '../scss/main.scss';
|
2017-08-22 00:10:52 +02:00
|
|
|
import { ws_init } from './socket';
|
|
|
|
import { filter_subscribe } from './actions/filter_subscribe';
|
2017-09-08 16:40:59 +02:00
|
|
|
import { socket_uri, socket_update, SOCKET_STATE } from './actions/socket';
|
2018-02-11 03:18:29 +01:00
|
|
|
import { search_criteria } from './search';
|
2017-08-22 00:10:52 +02:00
|
|
|
|
2017-08-22 21:49:48 +02:00
|
|
|
import Main from './ui/main';
|
2017-08-26 01:34:04 +02:00
|
|
|
import Connection from './ui/connection';
|
|
|
|
|
2017-09-07 11:35:15 +02:00
|
|
|
export function initialize(uri) {
|
2017-09-08 16:40:59 +02:00
|
|
|
store.dispatch(socket_uri(uri));
|
2017-09-08 06:55:47 +02:00
|
|
|
store.dispatch(socket_update(SOCKET_STATE.CONNECTING));
|
2017-09-07 11:35:15 +02:00
|
|
|
ws_init(uri, () => {
|
2017-12-30 19:06:59 +01:00
|
|
|
const qs = query.parse(window.location.search);
|
2017-09-08 06:55:47 +02:00
|
|
|
store.dispatch(socket_update(SOCKET_STATE.CONNECTED));
|
2017-12-30 19:06:59 +01:00
|
|
|
store.dispatch(filter_subscribe('torrent', search_criteria(qs.s)));
|
2017-09-07 11:35:15 +02:00
|
|
|
store.dispatch(filter_subscribe('server'));
|
2017-09-08 06:55:47 +02:00
|
|
|
}, () => {
|
|
|
|
store.dispatch(socket_update(SOCKET_STATE.DISCONNECTED,
|
|
|
|
"You were disconnected."));
|
2017-09-07 11:35:15 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-30 16:31:34 +01:00
|
|
|
const render = main =>
|
|
|
|
ReactDOM.render(
|
|
|
|
<Provider store={store}>
|
|
|
|
<ConnectedRouter history={history}>
|
2017-12-30 18:23:50 +01:00
|
|
|
{main}
|
2017-12-30 16:31:34 +01:00
|
|
|
</ConnectedRouter>
|
|
|
|
</Provider>, document.getElementById('root'));
|
|
|
|
|
|
|
|
render(<Main />);
|
|
|
|
|
|
|
|
if (module.hot) {
|
|
|
|
module.hot.accept('./ui/main.js', () => {
|
|
|
|
const NextMain = require('./ui/main.js').default;
|
2017-12-30 16:38:45 +01:00
|
|
|
render(<NextMain />);
|
2017-12-30 16:31:34 +01:00
|
|
|
});
|
|
|
|
}
|
2017-09-07 10:37:11 +02:00
|
|
|
|
|
|
|
navigator.registerProtocolHandler("magnet",
|
|
|
|
window.location.origin + "/add-torrent/%s",
|
|
|
|
"Open magnet link with receptor");
|
2017-12-29 20:56:41 +01:00
|
|
|
|
|
|
|
Notification && Notification.requestPermission();
|