lbry-desktop/ui/component/downloadProgress/index.js

25 lines
860 B
JavaScript
Raw Normal View History

2021-10-01 22:00:57 +02:00
import { connect } from 'react-redux';
import DownloadProgress from './view';
2021-10-05 18:20:34 +02:00
import { doSetPlayingUri, doStopDownload, doUpdateDownloadingStatus } from 'redux/actions/content';
import { selectFileInfosByOutpoint } from 'lbry-redux';
2021-10-01 22:00:57 +02:00
const select = (state) => {
2021-10-05 18:20:34 +02:00
const byOutpoint = selectFileInfosByOutpoint(state);
const runningByOutpoint = [];
for (const key in byOutpoint) {
if (byOutpoint[key] && byOutpoint[key].status === 'running') runningByOutpoint.push(byOutpoint[key]);
}
2021-10-01 22:00:57 +02:00
return {
2021-10-05 18:20:34 +02:00
downloadList: runningByOutpoint,
2021-10-01 22:00:57 +02:00
};
};
const perform = (dispatch) => ({
pause: () => dispatch(doSetPlayingUri({ uri: null })),
2021-10-05 18:20:34 +02:00
updateDownloadingStatus: (outpoint) => dispatch(doUpdateDownloadingStatus(outpoint)),
stopDownload: (outpoint) => dispatch(doStopDownload(outpoint)),
2021-10-01 22:00:57 +02:00
});
export default connect(select, perform)(DownloadProgress);