правильный тайтл на страницах

This commit is contained in:
Alexey Kasyanchuk
2017-01-14 00:11:57 +03:00
parent 1b799747eb
commit 8cfcdbaf3c
6 changed files with 38 additions and 11 deletions

View File

@ -3,6 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="fragment" content="!" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<title>BT Search</title> <title>BT Search</title>
</head> </head>

View File

@ -14,9 +14,27 @@ injectTapEventPlugin();
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
let loadersCount = 0;
let appReady = false;
window.customLoader = (func) => {
loadersCount++;
return (...args) => {
func(...args);
loadersCount--;
}
};
window.isReady = () => {
return (appReady && loadersCount === 0)
}
class App extends Component { class App extends Component {
componentDidMount() { componentDidMount() {
window.router() window.router()
appReady = true;
}
componentWillUnmount() {
appReady = false;
} }
render() { render() {
return ( return (

View File

@ -1,4 +1,5 @@
import React, { Component } from 'react'; import React from 'react';
import Page from './page';
import RecentTorrents from './recent-torrents' import RecentTorrents from './recent-torrents'
import Search from './search' import Search from './search'
@ -25,7 +26,11 @@ const Header = (props) => {
export {Header} export {Header}
export default class IndexPage extends Component { export default class IndexPage extends Page {
constructor(props) {
super(props)
this.setTitle('Welcome to files/torrents search engine');
}
render() { render() {
return ( return (
<div> <div>

View File

@ -172,7 +172,7 @@ export default class RecentTorrents extends Component {
this.state = { pause: false } this.state = { pause: false }
} }
componentDidMount() { componentDidMount() {
window.torrentSocket.emit('recentTorrents', (data) => { window.torrentSocket.emit('recentTorrents', window.customLoader((data) => {
if(data) { if(data) {
this.torrents = data; this.torrents = data;
this.forceUpdate(); this.forceUpdate();
@ -206,7 +206,7 @@ export default class RecentTorrents extends Component {
setTimeout(this.displayNewTorrent, speed); setTimeout(this.displayNewTorrent, speed);
} }
this.displayNewTorrent(); this.displayNewTorrent();
}); }));
this.newTorrentFunc = (torrent) => { this.newTorrentFunc = (torrent) => {
if(this.displayQueue.length < this.maxDisplaySize) { if(this.displayQueue.length < this.maxDisplaySize) {
this.displayQueue.push(torrent); this.displayQueue.push(torrent);

View File

@ -20,7 +20,7 @@ export default class Search extends Component {
}); });
this.searchData = []; this.searchData = [];
let queries = 2; let queries = 2;
window.torrentSocket.emit('searchTorrent', this.searchValue, {limit: 10}, (torrents) => { window.torrentSocket.emit('searchTorrent', this.searchValue, {limit: 10}, window.customLoader((torrents) => {
if(torrents) { if(torrents) {
this.searchData = this.searchData.concat(torrents); this.searchData = this.searchData.concat(torrents);
} }
@ -31,8 +31,8 @@ export default class Search extends Component {
} else { } else {
this.forceUpdate(); this.forceUpdate();
} }
}); }));
window.torrentSocket.emit('searchFiles', this.searchValue, {limit: 10}, (torrents) => { window.torrentSocket.emit('searchFiles', this.searchValue, {limit: 10}, window.customLoader((torrents) => {
if(torrents) { if(torrents) {
this.searchData = this.searchData.concat(torrents); this.searchData = this.searchData.concat(torrents);
} }
@ -43,7 +43,7 @@ export default class Search extends Component {
} else { } else {
this.forceUpdate(); this.forceUpdate();
} }
}); }));
} }
componentDidMount() { componentDidMount() {
this.newStatisticFunc = (statistic) => { this.newStatisticFunc = (statistic) => {
@ -52,7 +52,7 @@ export default class Search extends Component {
this.forceUpdate(); this.forceUpdate();
} }
}; };
window.torrentSocket.emit('statistic', this.newStatisticFunc); window.torrentSocket.emit('statistic', window.customLoader(this.newStatisticFunc));
window.torrentSocket.on('newStatistic', this.newStatisticFunc); window.torrentSocket.on('newStatistic', this.newStatisticFunc);
} }
componentWillUnmount() componentWillUnmount()

View File

@ -1,4 +1,5 @@
import React, { Component } from 'react'; import React from 'react';
import Page from './page';
import formatBytes from './format-bytes' import formatBytes from './format-bytes'
import {List, ListItem} from 'material-ui/List'; import {List, ListItem} from 'material-ui/List';
@ -118,12 +119,13 @@ const TorrentInformation = (props) => {
); );
} }
export default class TorrentPage extends Component { export default class TorrentPage extends Page {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
value: 'info', value: 'info',
}; };
this.setTitle('Information about torrent');
} }
handleChange = (value) => { handleChange = (value) => {
@ -140,6 +142,7 @@ export default class TorrentPage extends Component {
window.torrentSocket.emit('torrent', this.props.hash, {files: true}, (data) => { window.torrentSocket.emit('torrent', this.props.hash, {files: true}, (data) => {
if(data) { if(data) {
this.torrent = data this.torrent = data
this.setTitle('Download ' + this.torrent.name);
this.forceUpdate(); this.forceUpdate();
} }
}); });