Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
also cancel upload upon tap on header button
Browse files Browse the repository at this point in the history
  • Loading branch information
haveyaseen committed May 4, 2020
1 parent e69ff67 commit d5c8b13
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions App/screens/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,23 @@ export const Upload: React.FC<{
}).start(() => startAnimation());
};
startAnimation();
const cancelUpload = (): void => {
if (!deferUploadTimeout.current) {
console.warn('failed to clear deferUploadTimeout', deferUploadTimeout);
return;
}
console.log('clearing deferUploadTimeout', deferUploadTimeout);
clearTimeout(deferUploadTimeout.current);
deferUploadTimeout.current = null;
navigation.navigate('PositiveResult');
};

return (
<View style={[global.container]}>
<Header
navigationButton={{
title: t('global.cancel'),
fn: (): void => navigation.goBack(),
fn: cancelUpload,
}}
showHelp={true}
showAlpha={true}
Expand All @@ -84,19 +94,7 @@ export const Upload: React.FC<{
title={t('uploadData.buttonTitleCancel')}
variant="outlined"
buttonStyle={styles.cancelButton}
onPress={(): void => {
if (!deferUploadTimeout.current) {
console.warn(
'failed to clear deferUploadTimeout',
deferUploadTimeout,
);
return;
}
console.log('clearing deferUploadTimeout', deferUploadTimeout);
clearTimeout(deferUploadTimeout.current);
deferUploadTimeout.current = null;
navigation.navigate('PositiveResult');
}}
onPress={cancelUpload}
/>
</View>
);
Expand Down

0 comments on commit d5c8b13

Please sign in to comment.