подгрузка визуально
This commit is contained in:
@ -16,10 +16,16 @@ import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
|
|||||||
|
|
||||||
let loadersCount = 0;
|
let loadersCount = 0;
|
||||||
let appReady = false;
|
let appReady = false;
|
||||||
window.customLoader = (func) => {
|
window.customLoader = (func, onLoading, onLoaded) => {
|
||||||
loadersCount++;
|
loadersCount++;
|
||||||
|
if(onLoading) {
|
||||||
|
onLoading();
|
||||||
|
}
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
func(...args);
|
func(...args);
|
||||||
|
if(onLoaded) {
|
||||||
|
onLoaded();
|
||||||
|
}
|
||||||
loadersCount--;
|
loadersCount--;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ import Subheader from 'material-ui/Subheader';
|
|||||||
import Paper from 'material-ui/Paper';
|
import Paper from 'material-ui/Paper';
|
||||||
import Divider from 'material-ui/Divider';
|
import Divider from 'material-ui/Divider';
|
||||||
import FlatButton from 'material-ui/FlatButton';
|
import FlatButton from 'material-ui/FlatButton';
|
||||||
|
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
||||||
|
|
||||||
const TorrentLine = (props) => {
|
const TorrentLine = (props) => {
|
||||||
const torrent = props.torrent;
|
const torrent = props.torrent;
|
||||||
@ -169,13 +170,16 @@ export default class RecentTorrents extends Component {
|
|||||||
this.displayQueue = [];
|
this.displayQueue = [];
|
||||||
this.displayQueueAssoc = {};
|
this.displayQueueAssoc = {};
|
||||||
this.maxDisplaySize = 1000;
|
this.maxDisplaySize = 1000;
|
||||||
this.state = { pause: false }
|
this.state = {
|
||||||
|
pause: false,
|
||||||
|
searchingIndicator: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
window.torrentSocket.emit('recentTorrents', window.customLoader((data) => {
|
window.torrentSocket.emit('recentTorrents', window.customLoader((data) => {
|
||||||
if(data) {
|
if(data) {
|
||||||
this.torrents = data;
|
this.torrents = data;
|
||||||
this.forceUpdate();
|
//this.forceUpdate(); // вызывается через searchingIndicator
|
||||||
}
|
}
|
||||||
|
|
||||||
this.displayNewTorrent = () => {
|
this.displayNewTorrent = () => {
|
||||||
@ -206,7 +210,15 @@ export default class RecentTorrents extends Component {
|
|||||||
setTimeout(this.displayNewTorrent, speed);
|
setTimeout(this.displayNewTorrent, speed);
|
||||||
}
|
}
|
||||||
this.displayNewTorrent();
|
this.displayNewTorrent();
|
||||||
}));
|
}, () => {
|
||||||
|
this.setState({
|
||||||
|
searchingIndicator: true
|
||||||
|
});
|
||||||
|
}, () => {
|
||||||
|
this.setState({
|
||||||
|
searchingIndicator: false
|
||||||
|
});
|
||||||
|
}));
|
||||||
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);
|
||||||
@ -239,6 +251,28 @@ export default class RecentTorrents extends Component {
|
|||||||
delete this.displayNewTorrent;
|
delete this.displayNewTorrent;
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
const style = {
|
||||||
|
refresh: {
|
||||||
|
display: 'inline-block',
|
||||||
|
position: 'relative',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if(this.state.searchingIndicator) {
|
||||||
|
return (
|
||||||
|
<div className='pad1'>
|
||||||
|
<RefreshIndicator
|
||||||
|
size={50}
|
||||||
|
left={0}
|
||||||
|
top={0}
|
||||||
|
loadingColor="#FF9800"
|
||||||
|
status="loading"
|
||||||
|
style={style.refresh}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(!this.torrents || this.torrents.length == 0)
|
if(!this.torrents || this.torrents.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import FileFolder from 'material-ui/svg-icons/file/folder';
|
|||||||
import NoImage from './images/no-image-icon.png'
|
import NoImage from './images/no-image-icon.png'
|
||||||
|
|
||||||
var moment = require('moment');
|
var moment = require('moment');
|
||||||
|
import RefreshIndicator from 'material-ui/RefreshIndicator';
|
||||||
|
|
||||||
let buildFilesTree = (filesList) => {
|
let buildFilesTree = (filesList) => {
|
||||||
let rootTree = {
|
let rootTree = {
|
||||||
@ -124,6 +125,7 @@ export default class TorrentPage extends Page {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
value: 'info',
|
value: 'info',
|
||||||
|
searchingIndicator: false
|
||||||
};
|
};
|
||||||
this.setTitle('Information about torrent');
|
this.setTitle('Information about torrent');
|
||||||
}
|
}
|
||||||
@ -143,14 +145,22 @@ export default class TorrentPage extends Page {
|
|||||||
if(data) {
|
if(data) {
|
||||||
this.torrent = data
|
this.torrent = data
|
||||||
this.setTitle('Download ' + this.torrent.name);
|
this.setTitle('Download ' + this.torrent.name);
|
||||||
this.forceUpdate();
|
//this.forceUpdate(); // вызывается через searchingIndicator
|
||||||
|
|
||||||
// Получаем более новую статистику пира
|
// Получаем более новую статистику пира
|
||||||
if((new Date).getTime() - this.torrent.trackersChecked > 10 * 60 * 1000) {
|
if((new Date).getTime() - this.torrent.trackersChecked > 10 * 60 * 1000) {
|
||||||
window.torrentSocket.emit('checkTrackers', this.torrent.hash);
|
window.torrentSocket.emit('checkTrackers', this.torrent.hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}, () => {
|
||||||
|
this.setState({
|
||||||
|
searchingIndicator: true
|
||||||
|
});
|
||||||
|
}, () => {
|
||||||
|
this.setState({
|
||||||
|
searchingIndicator: false
|
||||||
|
});
|
||||||
|
}));
|
||||||
this.trackerUpdate = (info) => {
|
this.trackerUpdate = (info) => {
|
||||||
if(this.props.hash != info.hash)
|
if(this.props.hash != info.hash)
|
||||||
return;
|
return;
|
||||||
@ -168,6 +178,28 @@ export default class TorrentPage extends Page {
|
|||||||
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
const style = {
|
||||||
|
refresh: {
|
||||||
|
display: 'inline-block',
|
||||||
|
position: 'relative',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
if(this.state.searchingIndicator) {
|
||||||
|
return (
|
||||||
|
<div className='pad1 w100p column center'>
|
||||||
|
<RefreshIndicator
|
||||||
|
size={50}
|
||||||
|
left={0}
|
||||||
|
top={0}
|
||||||
|
loadingColor="#FF9800"
|
||||||
|
status="loading"
|
||||||
|
style={style.refresh}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w100p">
|
<div className="w100p">
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user