MM-17886 Do not wait to cancel the video download (#3166)
This commit is contained in:
parent
db144dc5a7
commit
0115610152
1 changed files with 12 additions and 13 deletions
|
|
@ -282,19 +282,16 @@ export default class Downloader extends PureComponent {
|
|||
if (this.mounted) {
|
||||
this.setState({
|
||||
progress: 100,
|
||||
}, () => {
|
||||
// need to wait a bit for the progress circle UI to update to the give progress
|
||||
setTimeout(async () => {
|
||||
if (this.state.didCancel) {
|
||||
try {
|
||||
await RNFetchBlob.fs.unlink(path);
|
||||
} finally {
|
||||
this.props.onDownloadCancel();
|
||||
}
|
||||
} else {
|
||||
this.props.onDownloadSuccess();
|
||||
}, async () => {
|
||||
if (this.state.didCancel) {
|
||||
try {
|
||||
await RNFetchBlob.fs.unlink(path);
|
||||
} finally {
|
||||
this.downloadDidCancel();
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
this.props.onDownloadSuccess();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -306,7 +303,9 @@ export default class Downloader extends PureComponent {
|
|||
} catch (error) {
|
||||
// cancellation throws so we need to catch
|
||||
if (downloadPath) {
|
||||
RNFetchBlob.fs.unlink(getLocalFilePathFromFile(downloadPath, file));
|
||||
RNFetchBlob.fs.unlink(getLocalFilePathFromFile(downloadPath, file)).catch(() => {
|
||||
// do nothing
|
||||
});
|
||||
}
|
||||
if (error.message !== 'cancelled' && this.mounted) {
|
||||
this.showDownloadFailedAlert();
|
||||
|
|
|
|||
Loading…
Reference in a new issue