aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/comments/ZoomInCropper.tsx17
-rw-r--r--src/components/moments/Moment.tsx2
-rw-r--r--src/routes/main/MainStackNavigator.tsx5
-rw-r--r--src/screens/moments/CameraScreen.tsx18
-rw-r--r--src/screens/profile/CaptionScreen.tsx16
-rw-r--r--src/services/MomentService.ts21
6 files changed, 43 insertions, 36 deletions
diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx
index cfd3cbbc..7fa88f6e 100644
--- a/src/components/comments/ZoomInCropper.tsx
+++ b/src/components/comments/ZoomInCropper.tsx
@@ -1,6 +1,7 @@
import {RouteProp} from '@react-navigation/core';
+import {useFocusEffect} from '@react-navigation/native';
import {StackNavigationProp} from '@react-navigation/stack';
-import React, {useEffect, useState} from 'react';
+import React, {useCallback, useEffect, useState} from 'react';
import {Image, StyleSheet, TouchableOpacity} from 'react-native';
import {normalize} from 'react-native-elements';
import ImageZoom, {IOnMove} from 'react-native-image-pan-zoom';
@@ -33,6 +34,19 @@ export const ZoomInCropper: React.FC<ZoomInCropperProps> = ({
const [y0, setY0] = useState<number>();
const [y1, setY1] = useState<number>();
+ useFocusEffect(
+ useCallback(() => {
+ navigation.dangerouslyGetParent()?.setOptions({
+ tabBarVisible: false,
+ });
+ return () => {
+ navigation.dangerouslyGetParent()?.setOptions({
+ tabBarVisible: true,
+ });
+ };
+ }, [navigation]),
+ );
+
// Setting original aspect ratio of image
useEffect(() => {
if (media.uri) {
@@ -65,7 +79,6 @@ export const ZoomInCropper: React.FC<ZoomInCropperProps> = ({
screenType,
title: title,
media: {
- filename: media.filename,
uri: croppedURL,
isVideo: false,
},
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx
index f057b329..50c60fd9 100644
--- a/src/components/moments/Moment.tsx
+++ b/src/components/moments/Moment.tsx
@@ -44,12 +44,10 @@ const Moment: React.FC<MomentProps> = ({
const navigation = useNavigation();
const navigateToCaptionScreenForVideo = (uri: string) => {
- const randHash = Math.random().toString(36).substring(7);
navigation.navigate('CaptionScreen', {
screenType,
title,
media: {
- filename: `poc_${randHash}.mov`,
uri,
isVideo: true,
},
diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx
index 21430d7a..a5d73988 100644
--- a/src/routes/main/MainStackNavigator.tsx
+++ b/src/routes/main/MainStackNavigator.tsx
@@ -37,14 +37,13 @@ export type MainStackParams = {
};
CaptionScreen: {
title?: string;
- media?: {filename: string; uri: string; isVideo: boolean};
+ media?: {uri: string; isVideo: boolean};
screenType: ScreenType;
selectedTags?: MomentTagType[];
moment?: MomentType;
};
TagFriendsScreen: {
media: {
- filename: string;
uri: string;
isVideo: boolean;
};
@@ -111,7 +110,7 @@ export type MainStackParams = {
Chat: undefined;
NewChatModal: undefined;
ZoomInCropper: {
- media: {filename: string; uri: string; isVideo: boolean};
+ media: {uri: string; isVideo: boolean};
screenType: ScreenType;
title: string;
};
diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx
index b3275764..104774c0 100644
--- a/src/screens/moments/CameraScreen.tsx
+++ b/src/screens/moments/CameraScreen.tsx
@@ -1,8 +1,9 @@
import CameraRoll from '@react-native-community/cameraroll';
import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs';
import {RouteProp} from '@react-navigation/core';
+import {useFocusEffect} from '@react-navigation/native';
import {StackNavigationProp} from '@react-navigation/stack';
-import React, {createRef, useEffect, useState} from 'react';
+import React, {createRef, useCallback, useEffect, useState} from 'react';
import {StyleSheet, TouchableOpacity, View} from 'react-native';
import {CameraType, FlashMode, RNCamera} from 'react-native-camera';
import CloseIcon from '../../assets/ionicons/close-outline.svg';
@@ -36,6 +37,19 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
const [mostRecentPhoto, setMostRecentPhoto] = useState<string>('');
const [showSaveButton, setShowSaveButton] = useState<boolean>(false);
+ useFocusEffect(
+ useCallback(() => {
+ navigation.dangerouslyGetParent()?.setOptions({
+ tabBarVisible: false,
+ });
+ return () => {
+ navigation.dangerouslyGetParent()?.setOptions({
+ tabBarVisible: true,
+ });
+ };
+ }, [navigation]),
+ );
+
/*
* Chooses the last picture from gallery to display as the gallery button icon
*/
@@ -61,7 +75,6 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
screenType,
title,
media: {
- filename: 'dont have that info',
uri: capturedImage,
isVideo: false, // TODO: false for now
},
@@ -131,7 +144,6 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
screenType,
title,
media: {
- filename: pic.filename,
uri: pic.path,
isVideo: false,
},
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 364b81a3..da3efb06 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -69,7 +69,6 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
selectedTags ? selectedTags : [],
);
const [taggedList, setTaggedList] = useState<string>('');
- const mediaFilename = moment ? undefined : route.params.media!.filename;
const mediaUri = moment ? moment.moment_url : route.params.media!.uri;
// TODO: change this once moment refactor is done
const isMediaAVideo = moment
@@ -138,7 +137,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
const handleShare = async () => {
setLoading(true);
- if (moment || !mediaFilename || !title) {
+ if (moment || !title) {
handleFailed();
return;
}
@@ -146,22 +145,16 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
let momentId;
// separate upload logic for image/video
if (isMediaAVideo) {
- const presignedURL = await handlePresignedURL(mediaFilename, title);
+ const presignedURL = await handlePresignedURL(title);
if (!presignedURL) {
handleFailed();
return;
}
momentId = presignedURL.moment_id;
// TODO: assume success for now
- await handleVideoUpload(mediaFilename, mediaUri, presignedURL);
+ await handleVideoUpload(mediaUri, presignedURL);
} else {
- const momentResponse = await postMoment(
- mediaFilename,
- mediaUri,
- caption,
- title,
- userId,
- );
+ const momentResponse = await postMoment(mediaUri, caption, title, userId);
if (!momentResponse) {
handleFailed();
return;
@@ -252,7 +245,6 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
onPress={() =>
navigation.navigate('TagFriendsScreen', {
media: {
- filename: mediaFilename ?? '',
uri: mediaUri,
isVideo: isMediaAVideo,
},
diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts
index b274ef04..ad0b0042 100644
--- a/src/services/MomentService.ts
+++ b/src/services/MomentService.ts
@@ -6,6 +6,7 @@ import {
MOMENT_TAGS_ENDPOINT,
MOMENT_THUMBNAIL_ENDPOINT,
PRESIGNED_URL_ENDPOINT,
+ RADIO_BUTTON_GREY,
TAGG_CUSTOMER_SUPPORT,
} from '../constants';
import {
@@ -16,7 +17,6 @@ import {MomentPostType, MomentTagType, PresignedURLResponse} from '../types';
import {checkImageUploadStatus} from '../utils';
export const postMoment = async (
- fileName: string,
uri: string,
caption: string,
category: string,
@@ -25,13 +25,9 @@ export const postMoment = async (
try {
const request = new FormData();
- //Manipulating filename to end with .jpg instead of .heic
- if (fileName.endsWith('.heic') || fileName.endsWith('.HEIC')) {
- fileName = fileName.split('.')[0] + '.jpg';
- }
request.append('image', {
uri: uri,
- name: fileName,
+ name: 'moment.jpg', // we don't care about filename, anything works
type: 'image/jpg',
});
request.append('moment', category);
@@ -219,14 +215,13 @@ export const deleteMomentTag = async (moment_tag_id: string) => {
* This function makes a request to the server in order to provide the client with a presigned URL.
* This is called first, in order for the client to directly upload a file to S3
* @param value: string | undefined
- * @param filename: string | undefined
* @returns a PresignedURLResponse object
*/
-export const handlePresignedURL = async (
- filename: string | undefined,
- momentCategory: string,
-) => {
+export const handlePresignedURL = async (momentCategory: string) => {
try {
+ // TODO: just a random filename for video poc, we should not need to once complete
+ const randHash = Math.random().toString(36).substring(7);
+ const filename = `[pc_${randHash}].mov`;
const token = await AsyncStorage.getItem('token');
const response = await fetch(PRESIGNED_URL_ENDPOINT, {
method: 'POST',
@@ -260,13 +255,11 @@ export const handlePresignedURL = async (
/**
* This util function takes in the file object and the PresignedURLResponse object, creates form data from the latter,
* and makes a post request to the presigned URL, sending the file object inside of the form data.
- * @param filename: the filename
* @param filePath: the path to the file, including filename
* @param urlObj PresignedURLResponse | undefined
* @returns responseURL or boolean
*/
export const handleVideoUpload = async (
- filename: string,
filePath: string,
urlObj: PresignedURLResponse | undefined,
) => {
@@ -297,7 +290,7 @@ export const handleVideoUpload = async (
uri: filePath,
// other types such as 'quicktime' 'image' etc exist, and we can programmatically type this, but for now sticking with simple 'video'
type: 'video',
- name: filename,
+ name: 'moment.mov', // we don't care about filename, anything works
});
const response = await fetch(urlObj.response_url.url, {
method: 'POST',