cleanup FileDownloadLink
This commit is contained in:
parent
f86bb14591
commit
2f4395a9e3
2 changed files with 5 additions and 24 deletions
|
@ -5,7 +5,6 @@ import {
|
|||
makeSelectLoadingForUri,
|
||||
makeSelectCostInfoForUri,
|
||||
} from 'lbry-redux';
|
||||
import { doFetchAvailability } from 'redux/actions/availability';
|
||||
import { doOpenFileInShell } from 'redux/actions/file';
|
||||
import { doPurchaseUri, doStartDownload } from 'redux/actions/content';
|
||||
import { doPause } from 'redux/actions/media';
|
||||
|
@ -20,7 +19,6 @@ const select = (state, props) => ({
|
|||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
checkAvailability: uri => dispatch(doFetchAvailability(uri)),
|
||||
openInShell: path => dispatch(doOpenFileInShell(path)),
|
||||
purchaseUri: uri => dispatch(doPurchaseUri(uri)),
|
||||
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
||||
|
|
|
@ -11,31 +11,19 @@ type Props = {
|
|||
total_bytes: number,
|
||||
outpoint: number,
|
||||
download_path: string,
|
||||
completed: boolean,
|
||||
},
|
||||
loading: boolean,
|
||||
costInfo: ?{},
|
||||
restartDownload: (string, number) => void,
|
||||
checkAvailability: string => void,
|
||||
openInShell: string => void,
|
||||
purchaseUri: string => void,
|
||||
doPause: () => void,
|
||||
};
|
||||
|
||||
class FileDownloadLink extends React.PureComponent<Props> {
|
||||
componentWillMount() {
|
||||
this.checkAvailability(this.props.uri);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: Props) {
|
||||
this.checkAvailability(nextProps.uri);
|
||||
this.restartDownload(nextProps);
|
||||
}
|
||||
|
||||
uri: ?string;
|
||||
|
||||
restartDownload = (props: Props) => {
|
||||
const { downloading, fileInfo, uri, restartDownload } = props;
|
||||
|
||||
componentWillUpdate() {
|
||||
const { downloading, fileInfo, uri, restartDownload } = this.props;
|
||||
if (
|
||||
!downloading &&
|
||||
fileInfo &&
|
||||
|
@ -45,15 +33,10 @@ class FileDownloadLink extends React.PureComponent<Props> {
|
|||
) {
|
||||
restartDownload(uri, fileInfo.outpoint);
|
||||
}
|
||||
};
|
||||
|
||||
checkAvailability(uri: string) {
|
||||
if (!this.uri || uri !== this.uri) {
|
||||
this.uri = uri;
|
||||
this.props.checkAvailability(uri);
|
||||
}
|
||||
}
|
||||
|
||||
uri: ?string;
|
||||
|
||||
render() {
|
||||
const {
|
||||
fileInfo,
|
||||
|
|
Loading…
Reference in a new issue