|
@@ -62,6 +62,8 @@ import ReactionsListModal from '../Components/ReactionsListModal';
|
|
import { dismissChatNotifications } from '../utils';
|
|
import { dismissChatNotifications } from '../utils';
|
|
import { useMessagesStore } from 'src/stores/unreadMessagesStore';
|
|
import { useMessagesStore } from 'src/stores/unreadMessagesStore';
|
|
|
|
|
|
|
|
+import BanIcon from 'assets/icons/messages/ban.svg';
|
|
|
|
+
|
|
const options = {
|
|
const options = {
|
|
enableVibrateFallback: true,
|
|
enableVibrateFallback: true,
|
|
ignoreAndroidSystemSettings: false
|
|
ignoreAndroidSystemSettings: false
|
|
@@ -71,7 +73,23 @@ const reactionEmojis = ['👍', '❤️', '😂', '😮', '😭'];
|
|
|
|
|
|
const ChatScreen = ({ route }: { route: any }) => {
|
|
const ChatScreen = ({ route }: { route: any }) => {
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
- const { id, name, avatar }: { id: number; name: string; avatar: string | null } = route.params;
|
|
|
|
|
|
+ const {
|
|
|
|
+ id,
|
|
|
|
+ name,
|
|
|
|
+ avatar,
|
|
|
|
+ userType
|
|
|
|
+ }: {
|
|
|
|
+ id: number;
|
|
|
|
+ name: string;
|
|
|
|
+ avatar: string | null;
|
|
|
|
+ userType: 'normal' | 'not_exist' | 'blocked';
|
|
|
|
+ } = route.params;
|
|
|
|
+ const userName =
|
|
|
|
+ userType === 'blocked'
|
|
|
|
+ ? 'Account is blocked'
|
|
|
|
+ : userType === 'not_exist'
|
|
|
|
+ ? 'Account does not exist'
|
|
|
|
+ : name;
|
|
|
|
|
|
const currentUserId = storage.get('uid', StoreType.STRING) as number;
|
|
const currentUserId = storage.get('uid', StoreType.STRING) as number;
|
|
const insets = useSafeAreaInsets();
|
|
const insets = useSafeAreaInsets();
|
|
@@ -411,14 +429,14 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
createdAt: new Date(message.sent_datetime + 'Z'),
|
|
createdAt: new Date(message.sent_datetime + 'Z'),
|
|
user: {
|
|
user: {
|
|
_id: message.sender,
|
|
_id: message.sender,
|
|
- name: message.sender === id ? name : 'Me'
|
|
|
|
|
|
+ name: message.sender === id ? userName : 'Me'
|
|
},
|
|
},
|
|
replyMessage:
|
|
replyMessage:
|
|
message.reply_to_id !== -1
|
|
message.reply_to_id !== -1
|
|
? {
|
|
? {
|
|
text: message.reply_to.text,
|
|
text: message.reply_to.text,
|
|
id: message.reply_to.id,
|
|
id: message.reply_to.id,
|
|
- name: message.reply_to.sender === id ? name : 'Me'
|
|
|
|
|
|
+ name: message.reply_to.sender === id ? userName : 'Me'
|
|
}
|
|
}
|
|
: null,
|
|
: null,
|
|
reactions: JSON.parse(message.reactions || '{}'),
|
|
reactions: JSON.parse(message.reactions || '{}'),
|
|
@@ -729,7 +747,7 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
openReactionList(
|
|
openReactionList(
|
|
time.currentMessage.reactions.map((reaction) => ({
|
|
time.currentMessage.reactions.map((reaction) => ({
|
|
...reaction,
|
|
...reaction,
|
|
- name: reaction.uid === id ? name : 'Me'
|
|
|
|
|
|
+ name: reaction.uid === id ? userName : 'Me'
|
|
})),
|
|
})),
|
|
time.currentMessage._id
|
|
time.currentMessage._id
|
|
)
|
|
)
|
|
@@ -820,7 +838,7 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
newMessages[0].replyMessage = {
|
|
newMessages[0].replyMessage = {
|
|
text: replyMessage.text,
|
|
text: replyMessage.text,
|
|
id: replyMessage._id,
|
|
id: replyMessage._id,
|
|
- name: replyMessage.user._id === id ? name : 'Me'
|
|
|
|
|
|
+ name: replyMessage.user._id === id ? userName : 'Me'
|
|
};
|
|
};
|
|
}
|
|
}
|
|
const message = { ...newMessages[0], pending: true };
|
|
const message = { ...newMessages[0], pending: true };
|
|
@@ -1158,7 +1176,7 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
>
|
|
>
|
|
<View style={{ paddingHorizontal: '5%' }}>
|
|
<View style={{ paddingHorizontal: '5%' }}>
|
|
<Header
|
|
<Header
|
|
- label={name}
|
|
|
|
|
|
+ label={userName}
|
|
rightElement={
|
|
rightElement={
|
|
<TouchableOpacity
|
|
<TouchableOpacity
|
|
onPress={() =>
|
|
onPress={() =>
|
|
@@ -1166,10 +1184,11 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: id }] as never)
|
|
...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId: id }] as never)
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
+ disabled={userType !== 'normal'}
|
|
>
|
|
>
|
|
- {avatar ? (
|
|
|
|
|
|
+ {avatar && userType === 'normal' ? (
|
|
<Image source={{ uri: API_HOST + avatar }} style={styles.avatar} />
|
|
<Image source={{ uri: API_HOST + avatar }} style={styles.avatar} />
|
|
- ) : (
|
|
|
|
|
|
+ ) : userType === 'normal' ? (
|
|
<AvatarWithInitials
|
|
<AvatarWithInitials
|
|
text={
|
|
text={
|
|
name
|
|
name
|
|
@@ -1181,6 +1200,8 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
size={30}
|
|
size={30}
|
|
fontSize={12}
|
|
fontSize={12}
|
|
/>
|
|
/>
|
|
|
|
+ ) : (
|
|
|
|
+ <BanIcon fill={Colors.RED} width={30} height={30} />
|
|
)}
|
|
)}
|
|
</TouchableOpacity>
|
|
</TouchableOpacity>
|
|
}
|
|
}
|