aboutsummaryrefslogtreecommitdiff
path: root/src/components/messages
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-04-07 15:23:34 -0400
committerIvan Chen <ivan@tagg.id>2021-04-07 15:23:34 -0400
commit952329c1ee1ebeee27d86d3dc09f4ceaa0b9f6a1 (patch)
tree1541b0a7a5a4abdf5570f2adfa6b6e52c3f6b6df /src/components/messages
parent8f0eb0703f24076796fa6c13e35b5fc8b8de87ab (diff)
added unread count
Diffstat (limited to 'src/components/messages')
-rw-r--r--src/components/messages/MessagesHeader.tsx10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/components/messages/MessagesHeader.tsx b/src/components/messages/MessagesHeader.tsx
index a3b31a22..2b20f48c 100644
--- a/src/components/messages/MessagesHeader.tsx
+++ b/src/components/messages/MessagesHeader.tsx
@@ -1,22 +1,26 @@
-import * as React from 'react';
+import React, {useContext} from 'react';
import {StyleSheet, View} from 'react-native';
import {Text} from 'react-native-animatable';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {normalize} from '../../utils';
import ComposeIcon from '../../assets/icons/compose.svg';
+import {ChatContext} from '../../App';
type MessagesHeaderProps = {
createChannel: () => void;
};
const MessagesHeader: React.FC<MessagesHeaderProps> = ({createChannel}) => {
+ const {chatClient} = useContext(ChatContext);
+ const unread = chatClient.user?.total_unread_count as number;
return (
<View style={styles.header}>
<Text style={styles.headerText}>Messages</Text>
- <Text style={styles.unreadText}>2 unread</Text>
+ {unread && unread !== 0 && (
+ <Text style={styles.unreadText}>{unread} unread</Text>
+ )}
<View style={styles.flex} />
<TouchableOpacity style={styles.compose} onPress={createChannel}>
- {/* <Text>Compose</Text> */}
<ComposeIcon width={normalize(20)} height={normalize(20)} />
</TouchableOpacity>
</View>