aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile/FriendsCount.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/profile/FriendsCount.tsx')
-rw-r--r--src/components/profile/FriendsCount.tsx21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/components/profile/FriendsCount.tsx b/src/components/profile/FriendsCount.tsx
index 851dbc3b..4790743b 100644
--- a/src/components/profile/FriendsCount.tsx
+++ b/src/components/profile/FriendsCount.tsx
@@ -1,11 +1,11 @@
+import {useNavigation} from '@react-navigation/native';
import React from 'react';
-import {View, Text, StyleSheet, ViewProps} from 'react-native';
+import {StyleSheet, Text, View, ViewProps} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
-import {useNavigation} from '@react-navigation/native';
+import {useSelector, useStore} from 'react-redux';
import {RootState} from '../../store/rootReducer';
-import {useSelector} from 'react-redux';
import {ScreenType} from '../../types';
-import {normalize} from '../../utils';
+import {canViewProfile, normalize} from '../../utils';
interface FriendsCountProps extends ViewProps {
userXId: string | undefined;
@@ -17,9 +17,9 @@ const FriendsCount: React.FC<FriendsCountProps> = ({
userXId,
screenType,
}) => {
- const {friends} = userXId
- ? useSelector((state: RootState) => state.userX[screenType][userXId])
- : useSelector((state: RootState) => state.friends);
+ const {friends} = useSelector((state: RootState) =>
+ userXId ? state.userX[screenType][userXId] : state.friends,
+ );
const count = friends ? friends.length : 0;
const displayedCount: string =
@@ -32,15 +32,18 @@ const FriendsCount: React.FC<FriendsCountProps> = ({
: `${count / 1e6}m`;
const navigation = useNavigation();
+ const state: RootState = useStore().getState();
return (
<TouchableOpacity
- style={{right: '20%'}}
onPress={() =>
- navigation.push('FriendsListScreen', {
+ navigation.navigate('FriendsListScreen', {
userXId,
screenType,
})
+ }
+ disabled={
+ !canViewProfile(state, userXId, screenType) || friends.length === 0
}>
<View style={[styles.container, style]}>
<Text style={styles.count}>{displayedCount}</Text>