Force stats refresh works better now on pause/unpause
This commit is contained in:
parent
79bd41a552
commit
e467787c38
2 changed files with 17 additions and 14 deletions
12
crates/librqbit/webui/dist/app.js
vendored
12
crates/librqbit/webui/dist/app.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -241,6 +241,11 @@ const Column: React.FC<{
|
||||||
const Torrent = ({ id, torrent }) => {
|
const Torrent = ({ id, torrent }) => {
|
||||||
const [detailsResponse, updateDetailsResponse] = useState<TorrentDetails>(null);
|
const [detailsResponse, updateDetailsResponse] = useState<TorrentDetails>(null);
|
||||||
const [statsResponse, updateStatsResponse] = useState<TorrentStats>(null);
|
const [statsResponse, updateStatsResponse] = useState<TorrentStats>(null);
|
||||||
|
const [forceStatsRefresh, setForceStatsRefresh] = useState(0);
|
||||||
|
|
||||||
|
const forceStatsRefreshCallback = () => {
|
||||||
|
setForceStatsRefresh(forceStatsRefresh + 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Update details once.
|
// Update details once.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -251,11 +256,6 @@ const Torrent = ({ id, torrent }) => {
|
||||||
}
|
}
|
||||||
}, [detailsResponse]);
|
}, [detailsResponse]);
|
||||||
|
|
||||||
const refreshStats = () => API.getTorrentStats(torrent.id).then((stats) => {
|
|
||||||
updateStatsResponse(stats);
|
|
||||||
return stats;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update stats once then forever.
|
// Update stats once then forever.
|
||||||
useEffect(() => customSetInterval((async () => {
|
useEffect(() => customSetInterval((async () => {
|
||||||
const errorInterval = 10000;
|
const errorInterval = 10000;
|
||||||
|
|
@ -263,7 +263,10 @@ const Torrent = ({ id, torrent }) => {
|
||||||
const finishedInterval = 10000;
|
const finishedInterval = 10000;
|
||||||
const nonLiveInterval = 10000;
|
const nonLiveInterval = 10000;
|
||||||
|
|
||||||
return refreshStats().then((stats) => {
|
return API.getTorrentStats(torrent.id).then((stats) => {
|
||||||
|
updateStatsResponse(stats);
|
||||||
|
return stats;
|
||||||
|
}).then((stats) => {
|
||||||
if (stats.finished) {
|
if (stats.finished) {
|
||||||
return finishedInterval;
|
return finishedInterval;
|
||||||
}
|
}
|
||||||
|
|
@ -274,9 +277,9 @@ const Torrent = ({ id, torrent }) => {
|
||||||
}, (e) => {
|
}, (e) => {
|
||||||
return errorInterval;
|
return errorInterval;
|
||||||
});
|
});
|
||||||
}), 0), []);
|
}), 0), [forceStatsRefresh]);
|
||||||
|
|
||||||
return <RefreshTorrentStatsContext.Provider value={{ refresh: refreshStats }}>
|
return <RefreshTorrentStatsContext.Provider value={{ refresh: forceStatsRefreshCallback }}>
|
||||||
<TorrentRow id={id} detailsResponse={detailsResponse} statsResponse={statsResponse} />
|
<TorrentRow id={id} detailsResponse={detailsResponse} statsResponse={statsResponse} />
|
||||||
</RefreshTorrentStatsContext.Provider >
|
</RefreshTorrentStatsContext.Provider >
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue