Add torrent fetching on the torrent page
This commit is contained in:
parent
f54b741c71
commit
8fc952b33c
@ -1,4 +1,4 @@
|
||||
import React, { useState } from "react"
|
||||
import React, { useState, useEffect } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { Map, List } from "immutable"
|
||||
import { connect } from "react-redux"
|
||||
@ -11,9 +11,19 @@ const mapDispatchToProps = {
|
||||
fetchTorrents, addTorrent, removeTorrent,
|
||||
};
|
||||
|
||||
// TODO: fecth every x seconds
|
||||
const TorrentList = (props) => {
|
||||
const [fetched, setIsFetched] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const intervalID = setInterval(() => {
|
||||
props.fetchTorrents();
|
||||
}, 10000);
|
||||
|
||||
return () => {
|
||||
clearInterval(intervalID);
|
||||
};
|
||||
});
|
||||
|
||||
if (!fetched) {
|
||||
props.fetchTorrents();
|
||||
setIsFetched(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user