aboutsummaryrefslogtreecommitdiff
path: root/src/screens/moments/CameraScreen.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/screens/moments/CameraScreen.tsx')
-rw-r--r--src/screens/moments/CameraScreen.tsx34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx
index c86f2efe..bd94bf63 100644
--- a/src/screens/moments/CameraScreen.tsx
+++ b/src/screens/moments/CameraScreen.tsx
@@ -33,12 +33,13 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
const [recordingStarted, setRecordingStarted] = useState<boolean>(false);
const [showCaptureButtons, setShowCaptureButtons] = useState<boolean>(false);
const [showCamera, setShowCamera] = useState<boolean>(true);
+ const [videoUri, setVideoUri] = useState<string | undefined>();
- const stopVideoRecording = async () => {
- if (await cameraRef.current?.isRecording()) {
- cameraRef.current?.stopRecording();
+ useEffect(() => {
+ if (recordingStarted && videoUri) {
+ navigateToEditMedia(videoUri);
}
- };
+ }, [videoUri]);
useFocusEffect(
useCallback(() => {
@@ -138,28 +139,13 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
: styles.captureButtonContainer
}
activeOpacity={1}
- onLongPress={async () => {
- await stopVideoRecording();
- takeVideo(cameraRef, (vid) => navigateToEditMedia(vid.uri));
- }}
- onPressOut={async () => {
+ onLongPress={() =>
+ takeVideo(cameraRef, (vid) => setVideoUri(vid.uri))
+ }
+ onPressOut={() => cameraRef.current?.stopRecording()}
+ onPress={() => {
setShowCaptureButtons(false);
- if (
- recordingStarted &&
- (await cameraRef.current?.isRecording())
- ) {
- cameraRef.current?.stopRecording();
- } else {
- takePicture(cameraRef, (pic) => navigateToEditMedia(pic.uri));
- }
- setRecordingStarted(false);
- }}
- onPress={async () => {
- if (showCaptureButtons) {
- setShowCaptureButtons(false);
- }
takePicture(cameraRef, (pic) => navigateToEditMedia(pic.uri));
- await stopVideoRecording();
}}>
<View style={styles.captureButton} />
</TouchableOpacity>