diff --git a/frontend/js/components/torrents/list.js b/frontend/js/components/torrents/list.js index 8f39c46..a20d5b3 100644 --- a/frontend/js/components/torrents/list.js +++ b/frontend/js/components/torrents/list.js @@ -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);