From a8963146c72be5b048d061df2dbcc322cb674877 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 14 May 2021 15:25:44 -0400 Subject: removed hacky fix, added state check --- src/components/common/BottomDrawer.tsx | 11 +++++------ src/components/moments/MomentPostHeader.tsx | 4 ---- src/components/profile/ProfileHeader.tsx | 4 ---- 3 files changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/components/common/BottomDrawer.tsx b/src/components/common/BottomDrawer.tsx index 3d9c0471..16e98690 100644 --- a/src/components/common/BottomDrawer.tsx +++ b/src/components/common/BottomDrawer.tsx @@ -71,15 +71,14 @@ const BottomDrawer: React.FC = (props) => { enabledContentGestureInteraction={false} callbackNode={bgAlpha} onCloseEnd={() => { - setModalVisible(false); - setIsOpen(false); + if (!isOpen) { + setModalVisible(false); + setIsOpen(false); + } }} /> - { - setIsOpen(false); - }}> + setIsOpen(false)}> diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index d2e9fc49..f8c79ad9 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -51,10 +51,6 @@ const MomentPostHeader: React.FC = ({ }); }; - useEffect(() => { - setDrawerVisible(drawerVisible); - }, [drawerVisible]); - return ( diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx index 14f7dc71..db5308b9 100644 --- a/src/components/profile/ProfileHeader.tsx +++ b/src/components/profile/ProfileHeader.tsx @@ -85,10 +85,6 @@ const ProfileHeader: React.FC = ({ } }; - useEffect(() => { - setDrawerVisible(drawerVisible); - }, [drawerVisible]); - return ( Date: Fri, 14 May 2021 17:18:17 -0400 Subject: changed to use https --- src/constants/api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/constants/api.ts b/src/constants/api.ts index 3c7e669e..ec67b6f9 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -5,7 +5,8 @@ const BASE_URL: string = 'http://127.0.0.1:8000/'; export const STREAM_CHAT_API = 'g2hvnyqx9cmv'; // Prod -// const BASE_URL: string = 'http://app-prod.tagg.id/'; +// const BASE_URL: string = 'https://app-prod2.tagg.id/'; +// const BASE_URL: string = 'https://app-prod3.tagg.id/'; // export const STREAM_CHAT_API = 'ur3kg5qz8x5v' const API_URL: string = BASE_URL + 'api/'; -- cgit v1.2.3-70-g09d2 From 33f5aa154457fb62099e56716ca5ae45feb98730 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 14 May 2021 17:50:36 -0400 Subject: linted --- src/components/comments/MentionInputControlled.tsx | 97 +++++++++++----------- src/components/moments/MomentPostHeader.tsx | 12 +-- 2 files changed, 56 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/components/comments/MentionInputControlled.tsx b/src/components/comments/MentionInputControlled.tsx index 6abcb566..2fd2b41d 100644 --- a/src/components/comments/MentionInputControlled.tsx +++ b/src/components/comments/MentionInputControlled.tsx @@ -6,7 +6,6 @@ import { TextInputSelectionChangeEventData, View, } from 'react-native'; - import { MentionInputProps, MentionPartType, @@ -43,16 +42,16 @@ const MentionInputControlled: FC = ({ const validRegex = () => { if (partTypes.length === 0) { - return /.*\@[^ ]*$/; + return /.*@[^ ]*$/; } else { - return new RegExp(`.*\@${keywordByTrigger[partTypes[0].trigger]}.*$`); + return new RegExp(`.*@${keywordByTrigger[partTypes[0].trigger]}.*$`); } }; - const {plainText, parts} = useMemo(() => parseValue(value, partTypes), [ - value, - partTypes, - ]); + const {plainText, parts} = useMemo( + () => parseValue(value, partTypes), + [value, partTypes], + ); const handleSelectionChange = ( event: NativeSyntheticEvent, @@ -91,36 +90,35 @@ const MentionInputControlled: FC = ({ * - Get updated value * - Trigger onChange callback with new value */ - const onSuggestionPress = (mentionType: MentionPartType) => ( - suggestion: Suggestion, - ) => { - const newValue = generateValueWithAddedSuggestion( - parts, - mentionType, - plainText, - selection, - suggestion, - ); - - if (!newValue) { - return; - } + const onSuggestionPress = + (mentionType: MentionPartType) => (suggestion: Suggestion) => { + const newValue = generateValueWithAddedSuggestion( + parts, + mentionType, + plainText, + selection, + suggestion, + ); + + if (!newValue) { + return; + } - onChange(newValue); + onChange(newValue); - /** - * Move cursor to the end of just added mention starting from trigger string and including: - * - Length of trigger string - * - Length of mention name - * - Length of space after mention (1) - * - * Not working now due to the RN bug - */ - // const newCursorPosition = currentPart.position.start + triggerPartIndex + trigger.length + - // suggestion.name.length + 1; + /** + * Move cursor to the end of just added mention starting from trigger string and including: + * - Length of trigger string + * - Length of mention name + * - Length of space after mention (1) + * + * Not working now due to the RN bug + */ + // const newCursorPosition = currentPart.position.start + triggerPartIndex + trigger.length + + // suggestion.name.length + 1; - // textInput.current?.setNativeProps({selection: {start: newCursorPosition, end: newCursorPosition}}); - }; + // textInput.current?.setNativeProps({selection: {start: newCursorPosition, end: newCursorPosition}}); + }; const handleTextInputRef = (ref: TextInput) => { textInput.current = ref as TextInput; @@ -129,7 +127,8 @@ const MentionInputControlled: FC = ({ if (typeof propInputRef === 'function') { propInputRef(ref); } else { - (propInputRef as MutableRefObject).current = ref as TextInput; + (propInputRef as MutableRefObject).current = + ref as TextInput; } } }; @@ -151,12 +150,14 @@ const MentionInputControlled: FC = ({ return ( {validateInput(keyboardText) - ? (partTypes.filter( - (one) => - isMentionPartType(one) && - one.renderSuggestions != null && - !one.isBottomMentionSuggestionsRender, - ) as MentionPartType[]).map(renderMentionSuggestions) + ? ( + partTypes.filter( + (one) => + isMentionPartType(one) && + one.renderSuggestions != null && + !one.isBottomMentionSuggestionsRender, + ) as MentionPartType[] + ).map(renderMentionSuggestions) : null} = ({ {validateInput(keyboardText) - ? (partTypes.filter( - (one) => - isMentionPartType(one) && - one.renderSuggestions != null && - one.isBottomMentionSuggestionsRender, - ) as MentionPartType[]).map(renderMentionSuggestions) + ? ( + partTypes.filter( + (one) => + isMentionPartType(one) && + one.renderSuggestions != null && + one.isBottomMentionSuggestionsRender, + ) as MentionPartType[] + ).map(renderMentionSuggestions) : null} ); diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index f8c79ad9..3c3ee4c3 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -1,4 +1,5 @@ -import React, {useEffect, useState} from 'react'; +import {useNavigation} from '@react-navigation/native'; +import React, {useState} from 'react'; import { StyleSheet, Text, @@ -6,14 +7,13 @@ import { View, ViewProps, } from 'react-native'; -import {MomentMoreInfoDrawer} from '../profile'; -import {loadUserMoments} from '../../store/actions'; import {useDispatch, useSelector, useStore} from 'react-redux'; -import {ScreenType} from '../../types'; -import TaggAvatar from '../profile/TaggAvatar'; -import {useNavigation} from '@react-navigation/native'; +import {loadUserMoments} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; +import {ScreenType} from '../../types'; import {fetchUserX, userXInStore} from '../../utils'; +import {MomentMoreInfoDrawer} from '../profile'; +import TaggAvatar from '../profile/TaggAvatar'; interface MomentPostHeaderProps extends ViewProps { userXId?: string; -- cgit v1.2.3-70-g09d2 From 37b37f296a59aea43e73f615ae6cb042b2242e87 Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Fri, 14 May 2021 19:33:03 -0700 Subject: Bug fixes --- src/components/common/Avatar.tsx | 23 ++++++++--- src/components/profile/Cover.tsx | 64 +++++++++++++++++++------------ src/components/profile/ProfileHeader.tsx | 1 + src/components/profile/TaggAvatar.tsx | 66 ++++++++++++++++++++++---------- 4 files changed, 105 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/components/common/Avatar.tsx b/src/components/common/Avatar.tsx index 831cf906..86ebedf3 100644 --- a/src/components/common/Avatar.tsx +++ b/src/components/common/Avatar.tsx @@ -1,17 +1,30 @@ import React, {FC} from 'react'; -import {Image, ImageStyle, StyleProp} from 'react-native'; +import {Image, ImageStyle, StyleProp, ImageBackground} from 'react-native'; type AvatarProps = { style: StyleProp; uri: string | undefined; + loading: boolean; + loadingStyle: StyleProp | undefined; }; -const Avatar: FC = ({style, uri}) => { +const Avatar: FC = ({ + style, + uri, + loading = false, + loadingStyle, +}) => { return ( - + source={{uri, cache: 'reload'}}> + {loading && ( + + )} + ); }; diff --git a/src/components/profile/Cover.tsx b/src/components/profile/Cover.tsx index 5d5b4234..2b6268a6 100644 --- a/src/components/profile/Cover.tsx +++ b/src/components/profile/Cover.tsx @@ -14,6 +14,7 @@ import {useDispatch, useSelector} from 'react-redux'; import {loadUserData, resetHeaderAndProfileImage} from '../../store/actions'; import {RootState} from '../../store/rootreducer'; import {normalize, patchProfile, validateImageLink} from '../../utils'; +import {useIsFocused} from '@react-navigation/native'; interface CoverProps { userXId: string | undefined; @@ -26,14 +27,22 @@ const Cover: React.FC = ({userXId, screenType}) => { ); const [needsUpdate, setNeedsUpdate] = useState(false); - const [loading, setLoading] = useState(false); + const [updating, setUpdating] = useState(false); + const [loading, setLoading] = useState(true); const [validImage, setValidImage] = useState(true); + const isFocused = useIsFocused(); useEffect(() => { - checkAvatar(cover); + checkCover(cover); + setLoading(false); }, []); useEffect(() => { + checkCover(cover); + }, [cover, isFocused]); + + useEffect(() => { + checkCover(cover); if (needsUpdate) { const userId = user.userId; const username = user.username; @@ -47,26 +56,35 @@ const Cover: React.FC = ({userXId, screenType}) => { const result = await patchProfile('header', user.userId); setLoading(true); if (result) { + setUpdating(true); setNeedsUpdate(true); + setLoading(false); } else { setLoading(false); } }; - const checkAvatar = async (url: string | undefined) => { + const checkCover = async (url: string | undefined) => { const valid = await validateImageLink(url); if (valid !== validImage) { setValidImage(valid); } + setLoading(false); }; - if (!validImage && userXId === undefined && !loading) { - return ( - - + return ( + + + {loading && ( + + )} + {!validImage && userXId === undefined && !loading && !updating && ( = ({userXId, screenType}) => { Add Picture - - - ); - } else { - return ( - - - - ); - } + )} + + + ); }; const styles = StyleSheet.create({ @@ -113,5 +121,13 @@ const styles = StyleSheet.create({ touch: { flex: 1, }, + loadingLarge: { + alignSelf: 'center', + justifyContent: 'center', + height: COVER_HEIGHT * 0.2, + width: IMAGE_WIDTH * 0.2, + aspectRatio: 1, + top: 100, + }, }); export default Cover; diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx index 14f7dc71..f3bc8e4b 100644 --- a/src/components/profile/ProfileHeader.tsx +++ b/src/components/profile/ProfileHeader.tsx @@ -115,6 +115,7 @@ const ProfileHeader: React.FC = ({ style={styles.avatar} userXId={userXId} screenType={screenType} + editable={true} /> diff --git a/src/components/profile/TaggAvatar.tsx b/src/components/profile/TaggAvatar.tsx index 304b9e3a..8ccae2ef 100644 --- a/src/components/profile/TaggAvatar.tsx +++ b/src/components/profile/TaggAvatar.tsx @@ -7,6 +7,7 @@ import {useDispatch, useSelector} from 'react-redux'; import {loadUserData, resetHeaderAndProfileImage} from '../../store/actions'; import PurplePlus from '../../assets/icons/purple-plus.svg'; import {patchProfile, validateImageLink} from '../../utils'; +import {useIsFocused} from '@react-navigation/native'; const PROFILE_DIM = 100; @@ -14,28 +15,35 @@ interface TaggAvatarProps { style?: object; userXId: string | undefined; screenType: ScreenType; + editable: boolean; } const TaggAvatar: React.FC = ({ style, screenType, userXId, + editable = false, }) => { - const {avatar} = useSelector((state: RootState) => + const {avatar, user} = useSelector((state: RootState) => userXId ? state.userX[screenType][userXId] : state.user, ); const dispatch = useDispatch(); const [needsUpdate, setNeedsUpdate] = useState(false); - const [loading, setLoading] = useState(false); + const [updating, setUpdating] = useState(false); + const [loading, setLoading] = useState(true); const [validImage, setValidImage] = useState(true); - const {user} = useSelector((state: RootState) => - userXId ? state.userX[screenType][userXId] : state.user, - ); + const isFocused = useIsFocused(); useEffect(() => { checkAvatar(avatar); + setLoading(false); }, []); useEffect(() => { + checkAvatar(avatar); + }, [avatar, isFocused]); + + useEffect(() => { + checkAvatar(avatar); if (needsUpdate) { const userId = user.userId; const username = user.username; @@ -47,8 +55,11 @@ const TaggAvatar: React.FC = ({ const handleNewImage = async () => { setLoading(true); const result = await patchProfile('profile', user.userId); + setLoading(true); if (result) { + setUpdating(true); setNeedsUpdate(true); + setLoading(false); } else { setLoading(false); } @@ -61,21 +72,28 @@ const TaggAvatar: React.FC = ({ } }; - if (!validImage && userXId === undefined && !loading) { - return ( - <> - - handleNewImage()}> - - - - ); - } else { - return ; - } + return ( + <> + + {editable && + !validImage && + userXId === undefined && + !loading && + !updating && ( + handleNewImage()}> + + + )} + + ); }; const styles = StyleSheet.create({ @@ -83,12 +101,20 @@ const styles = StyleSheet.create({ height: PROFILE_DIM, width: PROFILE_DIM, borderRadius: PROFILE_DIM / 2, + overflow: 'hidden', }, plus: { position: 'absolute', bottom: 35, right: 0, }, + loadingLarge: { + height: PROFILE_DIM * 0.8, + width: PROFILE_DIM * 0.8, + alignSelf: 'center', + justifyContent: 'center', + aspectRatio: 2, + }, }); export default TaggAvatar; -- cgit v1.2.3-70-g09d2 From 6a74b270d24f04e36821398b83863d5b97e1b44b Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Mon, 17 May 2021 12:01:22 -0700 Subject: Fixed bugs for plus sign in profile --- src/components/comments/CommentsContainer.tsx | 2 +- src/services/UserProfileService.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components/comments/CommentsContainer.tsx b/src/components/comments/CommentsContainer.tsx index 595ec743..d839ef38 100644 --- a/src/components/comments/CommentsContainer.tsx +++ b/src/components/comments/CommentsContainer.tsx @@ -49,7 +49,7 @@ const CommentsContainer: React.FC = ({ count += 1 + comments[i].replies_count; } return count; - } + }; useEffect(() => { const loadComments = async () => { diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 8b7b78e1..19d353aa 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -442,7 +442,7 @@ export const verifyExistingInformation = async ( const form = new FormData(); if (email) { form.append('email', email); - } + } if (username) { form.append('username', username); } @@ -453,7 +453,7 @@ export const verifyExistingInformation = async ( }, body: form, }); - return response.status===200; + return response.status === 200; } catch (error) { console.log(error); return false; -- cgit v1.2.3-70-g09d2 From 6958d07128082661c17a7d06778475983b8f4ccf Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 18 May 2021 18:01:32 -0400 Subject: Fix logic flow for invites --- src/components/friends/InviteFriendTile.tsx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/components/friends/InviteFriendTile.tsx b/src/components/friends/InviteFriendTile.tsx index abd017d0..355b88e8 100644 --- a/src/components/friends/InviteFriendTile.tsx +++ b/src/components/friends/InviteFriendTile.tsx @@ -46,22 +46,26 @@ const InviteFriendTile: React.FC = ({item}) => { { text: 'Yes!', onPress: async () => { - setInvited(true); - const inviteCode = await handleCreateInviteCode(); - await inviteFriendService( + const success = await inviteFriendService( item.phoneNumber, item.firstName, item.lastName, ); - Linking.openURL( - `sms:${item.phoneNumber}&body=${INVITE_USER_SMS_BODY( - item.firstName, - name, - inviteCode, - )}`, - ); - if (invites_left === 1) { - Alert.alert(SUCCESS_LAST_CONTACT_INVITE); + if (success) { + const inviteCode = await handleCreateInviteCode(); + setInvited(true); + Linking.openURL( + `sms:${item.phoneNumber}&body=${INVITE_USER_SMS_BODY( + item.firstName, + name, + inviteCode, + )}`, + ); + if (invites_left === 1) { + Alert.alert(SUCCESS_LAST_CONTACT_INVITE); + } + } else { + Alert.alert(ERROR_SOMETHING_WENT_WRONG); } }, }, -- cgit v1.2.3-70-g09d2