aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-19 13:47:47 -0400
committerGitHub <noreply@github.com>2021-03-19 13:47:47 -0400
commit65503e327d65d08b4fb2ec0acc886be4d17dadb3 (patch)
tree84b4d3f144fbc4764e94fef651cfc0cb82b15e4b /src/components
parent853b92cce77bd84fd93806b6519afa4ac4dde508 (diff)
parent65c5c5c461aa2a0551881774a16e4273c2d11023 (diff)
Merge pull request #308 from shravyaramesh/tma709-unfriend-button-on-userX-friendlist
[TMA-709] Unfriend button appears on userX's friend list
Diffstat (limited to 'src/components')
-rw-r--r--src/components/profile/Friends.tsx75
1 files changed, 35 insertions, 40 deletions
diff --git a/src/components/profile/Friends.tsx b/src/components/profile/Friends.tsx
index d87b0fb0..51ba6c64 100644
--- a/src/components/profile/Friends.tsx
+++ b/src/components/profile/Friends.tsx
@@ -26,12 +26,10 @@ interface FriendsProps {
}
const Friends: React.FC<FriendsProps> = ({result, screenType, userId}) => {
+ const state: RootState = useStore().getState();
const dispatch = useDispatch();
+ const {user: loggedInUser = NO_USER} = state;
const navigation = useNavigation();
- const {user: loggedInUser = NO_USER} = useSelector(
- (state: RootState) => state.user,
- );
- const state = useStore().getState();
const [usersFromContacts, setUsersFromContacts] = useState<
ProfilePreviewType[]
>([]);
@@ -88,42 +86,39 @@ const Friends: React.FC<FriendsProps> = ({result, screenType, userId}) => {
return (
<>
- {loggedInUser.userId === userId ||
- (userId === undefined && (
- <View style={styles.subheader}>
- <View style={styles.addFriendHeaderContainer}>
- <Text style={[styles.subheaderText]}>Add Friends</Text>
- <TouchableOpacity
- style={styles.findFriendsButton}
- onPress={async () => {
- const permission = await checkPermission();
- if (permission === 'authorized') {
- navigation.navigate('InviteFriendsScreen', {
- screenType: ScreenType.Profile,
- });
- } else {
- Alert.alert(
- '"Tagg" Would Like to Access Your Contacts',
- 'This helps you quickly get in touch with friends on the app and more',
- [
- {
- text: "Don't Allow",
- style: 'cancel',
- },
- {text: 'Allow', onPress: () => Linking.openSettings()},
- ],
- );
- }
- }}>
- <FindFriendsBlueIcon width={20} height={20} />
- <Text style={styles.findFriendsSubheaderText}>
- Find Friends
- </Text>
- </TouchableOpacity>
- </View>
- <UsersFromContacts />
+ {loggedInUser.userId === userId && (
+ <View style={styles.subheader}>
+ <View style={styles.addFriendHeaderContainer}>
+ <Text style={[styles.subheaderText]}>Add Friends</Text>
+ <TouchableOpacity
+ style={styles.findFriendsButton}
+ onPress={async () => {
+ const permission = await checkPermission();
+ if (permission === 'authorized') {
+ navigation.navigate('InviteFriendsScreen', {
+ screenType: ScreenType.Profile,
+ });
+ } else {
+ Alert.alert(
+ '"Tagg" Would Like to Access Your Contacts',
+ 'This helps you quickly get in touch with friends on the app and more',
+ [
+ {
+ text: "Don't Allow",
+ style: 'cancel',
+ },
+ {text: 'Allow', onPress: () => Linking.openSettings()},
+ ],
+ );
+ }
+ }}>
+ <FindFriendsBlueIcon width={20} height={20} />
+ <Text style={styles.findFriendsSubheaderText}>Find Friends</Text>
+ </TouchableOpacity>
</View>
- ))}
+ <UsersFromContacts />
+ </View>
+ )}
<Text style={[styles.subheaderText, styles.friendsSubheaderText]}>
Friends
</Text>
@@ -141,7 +136,7 @@ const Friends: React.FC<FriendsProps> = ({result, screenType, userId}) => {
screenType={screenType}
/>
</View>
- {loggedInUser.userId !== userId && (
+ {loggedInUser.userId === userId && (
<TouchableOpacity
style={styles.unfriendButton}
onPress={() =>