From ab13c937f1de947e68df03b443cf9fccb0cd54c9 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 22 Jun 2021 19:14:06 -0400 Subject: Add alert for gallery and camera --- src/services/MomentService.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/services') diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts index d0ed56ab..da6f9690 100644 --- a/src/services/MomentService.ts +++ b/src/services/MomentService.ts @@ -262,20 +262,17 @@ 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 file: Video, Image, Undefined + * @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 ( - file: Video | Image | undefined, + filename: string, + filePath: string, urlObj: PresignedURLResponse | undefined, ) => { try { - let fileName = file?.filename; - if (fileName === null || '') { - console.log('Invalid filename'); - return false; - } if (urlObj === null || urlObj === undefined) { console.log('Invalid urlObj'); return false; @@ -299,10 +296,10 @@ export const handleVideoUpload = async ( urlObj.response_url.fields['x-amz-signature'], ); form.append('file', { - uri: file?.sourceURL, + 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: filename, }); const response = await fetch(urlObj.response_url.url, { method: 'POST', -- cgit v1.2.3-70-g09d2 From 4ecc4525738dc8a56c9f37a05d0870e54cfa5be9 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 22 Jun 2021 19:21:26 -0400 Subject: Lint --- src/components/profile/ProfileBody.tsx | 2 -- src/constants/regex.ts | 2 +- src/screens/profile/IndividualMoment.tsx | 1 - src/services/MomentService.ts | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src/services') diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx index 048de696..cc001516 100644 --- a/src/components/profile/ProfileBody.tsx +++ b/src/components/profile/ProfileBody.tsx @@ -1,7 +1,5 @@ import React from 'react'; import {LayoutChangeEvent, Linking, StyleSheet, Text, View} from 'react-native'; -import {TouchableOpacity} from 'react-native-gesture-handler'; -import {launchCamera} from 'react-native-image-picker'; import {useDispatch, useSelector, useStore} from 'react-redux'; import {TAGG_DARK_BLUE, TOGGLE_BUTTON_TYPE} from '../../constants'; import { diff --git a/src/constants/regex.ts b/src/constants/regex.ts index f934185d..61523203 100644 --- a/src/constants/regex.ts +++ b/src/constants/regex.ts @@ -36,7 +36,7 @@ export const nameRegex: RegExp = /^[A-Za-z'\-,. ]{2,20}$/; * - match alphanumerics, and special characters used in URLs */ export const websiteRegex: RegExp = - /^$|^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,50}\.[a-zA-Z0-9()]{2,6}\b([-a-zA-Z0-9()@:%_+.~#?&\/=]{0,35})$/; + /^$|^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,50}\.[a-zA-Z0-9()]{2,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]{0,35})$/; /** * The website regex has the following constraints diff --git a/src/screens/profile/IndividualMoment.tsx b/src/screens/profile/IndividualMoment.tsx index cc176cd3..f8113aba 100644 --- a/src/screens/profile/IndividualMoment.tsx +++ b/src/screens/profile/IndividualMoment.tsx @@ -9,7 +9,6 @@ import {AVATAR_DIM} from '../../constants'; import {MainStackParams} from '../../routes'; import {RootState} from '../../store/rootreducer'; import {MomentPostType} from '../../types'; -import Video from 'react-native-video'; import { isIPhoneX, normalize, diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts index da6f9690..da1bfb97 100644 --- a/src/services/MomentService.ts +++ b/src/services/MomentService.ts @@ -1,5 +1,4 @@ import AsyncStorage from '@react-native-community/async-storage'; -import {Image, Video} from 'react-native-image-crop-picker'; import RNFetchBlob from 'rn-fetch-blob'; import { MOMENTS_ENDPOINT, -- cgit v1.2.3-70-g09d2