MM-17886 Do not wait to cancel the video download (#3166)

This commit is contained in:
Mattermost Build 2019-08-23 02:55:11 +02:00 committed by Elias Nahum
parent db144dc5a7
commit 0115610152

View file

@ -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();