From a74bc24d29366917c33aea240a9a71e595d8c55f Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 21 Apr 2021 15:23:09 -0400 Subject: fixed --- src/routes/main/MainStackScreen.tsx | 47 ++++++---------------- .../suggestedPeople/SuggestedPeopleScreen.tsx | 9 +++++ 2 files changed, 21 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index 37867151..f5100e58 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,7 +1,6 @@ -import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React, {useEffect, useState} from 'react'; +import React from 'react'; import {StyleSheet, Text} from 'react-native'; import {normalize} from 'react-native-elements'; import BackIcon from '../../assets/icons/back-arrow.svg'; @@ -56,28 +55,9 @@ interface MainStackProps { const MainStackScreen: React.FC = ({route}) => { const {screenType} = route.params; - // const isProfileTab = screenType === ScreenType.Profile; const isSearchTab = screenType === ScreenType.Search; const isNotificationsTab = screenType === ScreenType.Notifications; const isSuggestedPeopleTab = screenType === ScreenType.SuggestedPeople; - const [respondedToAccessContacts, setRespondedToAccessContacts] = useState( - 'true', - ); - - useEffect(() => { - loadResponseToAccessContacts(); - }, []); - - const loadResponseToAccessContacts = () => { - AsyncStorage.getItem('respondedToAccessContacts') - .then((value) => { - setRespondedToAccessContacts(value ? value : 'false'); - }) - .catch((error) => { - console.log('Something went wrong', error); - setRespondedToAccessContacts('true'); - }); - }; const initialRouteName = (() => { switch (screenType) { @@ -131,20 +111,13 @@ const MainStackScreen: React.FC = ({route}) => { ...headerBarOptions('white', ''), }} /> - {isSuggestedPeopleTab && - (respondedToAccessContacts && respondedToAccessContacts === 'true' ? ( - - ) : ( - - ))} + {isSuggestedPeopleTab && ( + + )} {isNotificationsTab && ( = ({route}) => { name="RequestContactsAccess" component={RequestContactsAccess} initialParams={{screenType}} + options={{ + ...modalStyle, + gestureEnabled: false, + }} /> { const stausBarRef = useRef(hideStatusBar); + useEffect(() => { + AsyncStorage.getItem('respondedToAccessContacts').then((value) => { + if (value === null) { + navigation.navigate('RequestContactsAccess'); + } + }); + }, []); + // loads data and append it to users based on current page useEffect(() => { loadMore(); -- cgit v1.2.3-70-g09d2 From 674c73eceda431993975d13dc47a6370e7b63d66 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Apr 2021 18:43:37 -0400 Subject: added delete button --- src/components/messages/ChannelPreview.tsx | 112 ++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/components/messages/ChannelPreview.tsx b/src/components/messages/ChannelPreview.tsx index 8bd3a745..6b166b55 100644 --- a/src/components/messages/ChannelPreview.tsx +++ b/src/components/messages/ChannelPreview.tsx @@ -1,10 +1,15 @@ import {useNavigation} from '@react-navigation/core'; import React, {useContext} from 'react'; import {Image, StyleSheet, Text, View} from 'react-native'; -import {TouchableOpacity} from 'react-native-gesture-handler'; +import { + RectButton, + Swipeable, + TouchableOpacity, +} from 'react-native-gesture-handler'; import {useStore} from 'react-redux'; import {ChannelPreviewMessengerProps} from 'stream-chat-react-native'; import {ChatContext} from '../../App'; +import Trash from '../../assets/ionicons/trash-outline.svg'; import {TAGG_LIGHT_BLUE_2} from '../../constants'; import { LocalAttachmentType, @@ -38,39 +43,59 @@ const ChannelPreview: React.FC< const unread = channel.state.unreadCount > 0; return ( - { - setChannel(channel); - navigation.navigate('Chat'); - }}> - - - {online && } - - - - {member?.user?.first_name} {member?.user?.last_name} - - - {channel.state.messages.length > 0 - ? channel.state.messages[channel.state.messages.length - 1].text - : ''} - - - {unread && } - + ( + + { + channel.delete(); + }}> + + Delete + + + )}> + { + setChannel(channel); + navigation.navigate('Chat'); + }}> + + + {online && } + + + + {member?.user?.first_name} {member?.user?.last_name} + + + {channel.state.messages.length > 0 + ? channel.state.messages[channel.state.messages.length - 1].text + : ''} + + + {unread && } + + ); }; @@ -128,6 +153,25 @@ const styles = StyleSheet.create({ borderRadius: normalize(10) / 2, marginLeft: '5%', }, + swipeableContainer: { + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#C42634', + }, + rightSwipeableButton: { + width: 72, + height: 62, + justifyContent: 'center', + alignItems: 'center', + }, + actionText: { + color: 'white', + fontSize: normalize(12), + fontWeight: '500', + backgroundColor: 'transparent', + paddingHorizontal: '5%', + marginTop: '5%', + }, }); export default ChannelPreview; -- cgit v1.2.3-70-g09d2 From 3a6024fc8282f81845df3643c1a3c7ec38746c71 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Apr 2021 18:57:17 -0400 Subject: added mute/unmute --- src/assets/images/mute.png | Bin 0 -> 1560 bytes src/assets/images/unmute.png | Bin 0 -> 1279 bytes src/components/messages/ChannelPreview.tsx | 41 ++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 src/assets/images/mute.png create mode 100644 src/assets/images/unmute.png (limited to 'src') diff --git a/src/assets/images/mute.png b/src/assets/images/mute.png new file mode 100644 index 00000000..b330e259 Binary files /dev/null and b/src/assets/images/mute.png differ diff --git a/src/assets/images/unmute.png b/src/assets/images/unmute.png new file mode 100644 index 00000000..7fe1782d Binary files /dev/null and b/src/assets/images/unmute.png differ diff --git a/src/components/messages/ChannelPreview.tsx b/src/components/messages/ChannelPreview.tsx index 6b166b55..f2662b6a 100644 --- a/src/components/messages/ChannelPreview.tsx +++ b/src/components/messages/ChannelPreview.tsx @@ -41,6 +41,10 @@ const ChannelPreview: React.FC< const member = getMember(channel, state); const online = isOnline(member?.user?.last_active); const unread = channel.state.unreadCount > 0; + const isMuted = channel.muteStatus().muted; + const mutedImage = isMuted + ? require('../../assets/images/unmute.png') + : require('../../assets/images/mute.png'); return ( ( { - channel.delete(); + channel.mute(); + console.log(channel.muteStatus()); }}> - + + {isMuted ? 'Unmute' : 'Mute'} + + { + channel.hide(); + }}> + Delete @@ -156,13 +165,21 @@ const styles = StyleSheet.create({ swipeableContainer: { alignItems: 'center', justifyContent: 'center', - backgroundColor: '#C42634', + flexDirection: 'row', }, - rightSwipeableButton: { + muteButton: { width: 72, - height: 62, + height: '100%', justifyContent: 'center', alignItems: 'center', + backgroundColor: '#C4C4C4', + }, + deleteButton: { + width: 72, + height: '100%', + justifyContent: 'center', + alignItems: 'center', + backgroundColor: '#C42634', }, actionText: { color: 'white', @@ -172,6 +189,10 @@ const styles = StyleSheet.create({ paddingHorizontal: '5%', marginTop: '5%', }, + icon: { + width: normalize(25), + height: normalize(25), + }, }); export default ChannelPreview; -- cgit v1.2.3-70-g09d2 From 70ff7ff583e03606bd3196082ea5faa05244e681 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Apr 2021 18:59:05 -0400 Subject: removed dead code --- src/screens/chat/ChatScreen.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/screens/chat/ChatScreen.tsx b/src/screens/chat/ChatScreen.tsx index 57f2232e..5874b8b6 100644 --- a/src/screens/chat/ChatScreen.tsx +++ b/src/screens/chat/ChatScreen.tsx @@ -154,7 +154,6 @@ const ChatScreen: React.FC = () => { myMessageTheme={loggedInUsersMessageTheme} MessageAvatar={MessageAvatar}> {}} /> - {/* */} -- cgit v1.2.3-70-g09d2 From 80237632843c123253b572f571bb6c336a4fad4e Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Apr 2021 19:01:16 -0400 Subject: fixed mute toggle --- src/components/messages/ChannelPreview.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/messages/ChannelPreview.tsx b/src/components/messages/ChannelPreview.tsx index f2662b6a..4a0cee0b 100644 --- a/src/components/messages/ChannelPreview.tsx +++ b/src/components/messages/ChannelPreview.tsx @@ -55,8 +55,11 @@ const ChannelPreview: React.FC< { - channel.mute(); - console.log(channel.muteStatus()); + if (isMuted) { + channel.unmute(); + } else { + channel.mute(); + } }}> {isMuted ? 'Unmute' : 'Mute'} -- cgit v1.2.3-70-g09d2 From 7e646506d805620ec3673d61219e44fd01a68930 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Apr 2021 19:17:11 -0400 Subject: added logic to hide channel --- src/screens/chat/ChatScreen.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/screens/chat/ChatScreen.tsx b/src/screens/chat/ChatScreen.tsx index 57f2232e..3cab3d25 100644 --- a/src/screens/chat/ChatScreen.tsx +++ b/src/screens/chat/ChatScreen.tsx @@ -125,6 +125,15 @@ const ChatScreen: React.FC = () => { }, }; + // Hide channel if no message was exchanged + useEffect(() => { + return () => { + if (channel?.state.messages.length === 0) { + channel.hide(); + } + }; + }, []); + useEffect(() => { setTopInset(insets.top + HeaderHeight); }); -- cgit v1.2.3-70-g09d2 From 9fccb2c81f4ccd4bf2891929c8e91d167827548c Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 22 Apr 2021 19:29:47 -0400 Subject: changed method --- src/components/messages/ChannelPreview.tsx | 5 +++++ src/screens/chat/ChatScreen.tsx | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/components/messages/ChannelPreview.tsx b/src/components/messages/ChannelPreview.tsx index 8bd3a745..4c3eb9d8 100644 --- a/src/components/messages/ChannelPreview.tsx +++ b/src/components/messages/ChannelPreview.tsx @@ -37,6 +37,11 @@ const ChannelPreview: React.FC< const online = isOnline(member?.user?.last_active); const unread = channel.state.unreadCount > 0; + // Hide channel if no message was exchanged + if (channel.state.messages.length === 0) { + return null; + } + return ( = () => { }, }; - // Hide channel if no message was exchanged - useEffect(() => { - return () => { - if (channel?.state.messages.length === 0) { - channel.hide(); - } - }; - }, []); - useEffect(() => { setTopInset(insets.top + HeaderHeight); }); -- cgit v1.2.3-70-g09d2 From dd0ccf25aaec5d0ef4a9e8a38e97cd8b03bad0a1 Mon Sep 17 00:00:00 2001 From: ankit-thanekar007 Date: Thu, 22 Apr 2021 16:44:48 -0700 Subject: Private Hotifix --- src/components/common/BadgeDetailView.tsx | 2 +- src/components/profile/Content.tsx | 8 +++++++- src/components/profile/ProfileHeader.tsx | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/components/common/BadgeDetailView.tsx b/src/components/common/BadgeDetailView.tsx index 32cc7aa4..437b1914 100644 --- a/src/components/common/BadgeDetailView.tsx +++ b/src/components/common/BadgeDetailView.tsx @@ -78,7 +78,7 @@ const BadgeDetailView: React.FC = ({ setTimeout(() => { setSelectedBadgesWithImage(badgesWithImage); setIsLoading(false); - }, 500); + }, 250); }, [selectedBadges]); const removeBadgeCell = async (badge: string) => { diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index c70d6df5..8298dc9a 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -145,7 +145,13 @@ const Content: React.FC = ({userXId, screenType}) => { void; + isPrivate?: boolean; }; const ProfileHeader: React.FC = ({ @@ -24,6 +25,7 @@ const ProfileHeader: React.FC = ({ screenType, isBlocked, handleBlockUnblock, + isPrivate, }) => { const { profile: {name = '', university_class = 2021, university}, @@ -67,7 +69,12 @@ const ProfileHeader: React.FC = ({ )} - setBadgeViewVisible(true)}> + { + if (!isPrivate) { + setBadgeViewVisible(true); + } + }}> -- cgit v1.2.3-70-g09d2 From 285d00db1e63342fad890edc2e1fcd09f0301cbd Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Apr 2021 15:34:01 -0400 Subject: fixed device not registering bug --- src/routes/Routes.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index 6fc766ab..c2efbb15 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -54,7 +54,7 @@ const Routes: React.FC = () => { fcmService.setUpPushNotifications(); fcmService.sendFcmTokenToServer(); } - }, []); + }); useEffect(() => { if (loggedInUserId) { -- cgit v1.2.3-70-g09d2 From 77082b5cd9c095af6fc289ed24b284c4b738a59d Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Apr 2021 15:34:12 -0400 Subject: sending fcm token to stream --- src/routes/Routes.tsx | 2 +- src/services/FCMService.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index c2efbb15..384021bc 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -52,7 +52,7 @@ const Routes: React.FC = () => { useEffect(() => { if (userId) { fcmService.setUpPushNotifications(); - fcmService.sendFcmTokenToServer(); + fcmService.sendFcmTokenToServer(chatClient); } }); diff --git a/src/services/FCMService.ts b/src/services/FCMService.ts index 84f30f09..711483ec 100644 --- a/src/services/FCMService.ts +++ b/src/services/FCMService.ts @@ -2,8 +2,10 @@ import AsyncStorage from '@react-native-community/async-storage'; import messaging from '@react-native-firebase/messaging'; import {Platform} from 'react-native'; import {getDeviceId, getDeviceName} from 'react-native-device-info'; +import {StreamChat} from 'stream-chat'; import {FCM_ENDPOINT} from '../constants'; import * as RootNavigation from '../RootNavigation'; + class FCMService { setUpPushNotifications = () => { // Requesting user to permit notifications @@ -78,10 +80,13 @@ class FCMService { return ''; }; - sendFcmTokenToServer = async () => { + sendFcmTokenToServer = async (chatClient: StreamChat) => { const registration_id: string | null = await AsyncStorage.getItem( '@fcmToken', ); + if (registration_id !== null) { + chatClient.addDevice(registration_id, 'firebase'); + } const device_id = getDeviceId(); const type = Platform.OS; let active: boolean = false; @@ -117,7 +122,6 @@ class FCMService { console.log('Successfully stored device token!'); } else { console.log('Failed to store device token!'); - console.log(response); } } }; -- cgit v1.2.3-70-g09d2 From 1c225f0dd7caaffa9501f9a86a1e1f9937b36f56 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Apr 2021 16:09:58 -0400 Subject: fixed slowness --- src/components/messages/ChannelPreview.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/messages/ChannelPreview.tsx b/src/components/messages/ChannelPreview.tsx index 4a0cee0b..87b94179 100644 --- a/src/components/messages/ChannelPreview.tsx +++ b/src/components/messages/ChannelPreview.tsx @@ -1,5 +1,5 @@ import {useNavigation} from '@react-navigation/core'; -import React, {useContext} from 'react'; +import React, {useContext, useState} from 'react'; import {Image, StyleSheet, Text, View} from 'react-native'; import { RectButton, @@ -41,7 +41,7 @@ const ChannelPreview: React.FC< const member = getMember(channel, state); const online = isOnline(member?.user?.last_active); const unread = channel.state.unreadCount > 0; - const isMuted = channel.muteStatus().muted; + const [isMuted, setIsMuted] = useState(channel.muteStatus().muted); const mutedImage = isMuted ? require('../../assets/images/unmute.png') : require('../../assets/images/mute.png'); @@ -60,6 +60,7 @@ const ChannelPreview: React.FC< } else { channel.mute(); } + setIsMuted(!isMuted); }}> {isMuted ? 'Unmute' : 'Mute'} -- cgit v1.2.3-70-g09d2 From 56f6c706ab8b85af2a09130dfc14ece872f3eaca Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 23 Apr 2021 18:00:24 -0400 Subject: changed to useSelector --- src/components/taggs/Tagg.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx index 94011e86..4a58bacb 100644 --- a/src/components/taggs/Tagg.tsx +++ b/src/components/taggs/Tagg.tsx @@ -1,31 +1,31 @@ import {useNavigation} from '@react-navigation/native'; import React, {Fragment, useState} from 'react'; import {Alert, Linking, StyleSheet, TouchableOpacity, View} from 'react-native'; +import {useSelector} from 'react-redux'; import PurpleRingPlus from '../../assets/icons/purple_ring+.svg'; import PurpleRing from '../../assets/icons/purple_ring.svg'; import RingPlus from '../../assets/icons/ring+.svg'; -import Ring from '../../assets/icons/ring.svg'; import WhiteRing from '../../assets/icons/ring-white.svg'; +import Ring from '../../assets/icons/ring.svg'; import { INTEGRATED_SOCIAL_LIST, SOCIAL_ICON_SIZE_ADJUSTMENT, TAGG_RING_DIM, } from '../../constants'; +import { + ERROR_LINK, + ERROR_UNABLE_TO_FIND_PROFILE, + SUCCESS_LINK, +} from '../../constants/strings'; import { getNonIntegratedURL, handlePressForAuthBrowser, registerNonIntegratedSocialLink, } from '../../services'; -import {SmallSocialIcon, SocialIcon, SocialLinkModal} from '../common'; +import {RootState} from '../../store/rootReducer'; import {ScreenType, UserType} from '../../types'; -import { - ERROR_LINK, - ERROR_UNABLE_TO_FIND_PROFILE, - SUCCESS_LINK, -} from '../../constants/strings'; import {canViewProfile, normalize} from '../../utils'; -import {RootState} from '../../store/rootReducer'; -import {useStore} from 'react-redux'; +import {SmallSocialIcon, SocialIcon, SocialLinkModal} from '../common'; interface TaggProps { social: string; @@ -51,7 +51,7 @@ const Tagg: React.FC = ({ whiteRing, }) => { const navigation = useNavigation(); - const state: RootState = useStore().getState(); + const state = useSelector((s: RootState) => s); const [modalVisible, setModalVisible] = useState(false); const youMayPass = isLinked || userXId; -- cgit v1.2.3-70-g09d2