From bb16e95e15f6ea9b8941cae764570bdf7c0fdb59 Mon Sep 17 00:00:00 2001
From: Ivan Chen <ivan@tagg.id>
Date: Thu, 8 Apr 2021 16:10:14 -0400
Subject: created util functions, updated isOnline

---
 src/screens/chat/ChatScreen.tsx | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'src/screens/chat/ChatScreen.tsx')

diff --git a/src/screens/chat/ChatScreen.tsx b/src/screens/chat/ChatScreen.tsx
index eeb1a7d6..8e6c1575 100644
--- a/src/screens/chat/ChatScreen.tsx
+++ b/src/screens/chat/ChatScreen.tsx
@@ -2,6 +2,7 @@ import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs';
 import {StackNavigationProp, useHeaderHeight} from '@react-navigation/stack';
 import React, {useContext} from 'react';
 import {StyleSheet, View} from 'react-native';
+import {useSelector} from 'react-redux';
 import {
   Channel,
   Chat,
@@ -10,6 +11,7 @@ import {
 } from 'stream-chat-react-native';
 import {ChatContext} from '../../App';
 import {MainStackParams} from '../../routes';
+import {RootState} from '../../store/rootReducer';
 
 type ChatScreenNavigationProp = StackNavigationProp<MainStackParams, 'Chat'>;
 interface ChatScreenProps {
@@ -22,6 +24,15 @@ const ChatScreen: React.FC<ChatScreenProps> = () => {
   const {channel, chatClient} = useContext(ChatContext);
   const headerHeight = useHeaderHeight();
   const tabbarHeight = useBottomTabBarHeight();
+  const {userId: loggedInUserId} = useSelector(
+    (state: RootState) => state.user.user,
+  );
+  const otherMembers = channel
+    ? Object.values(channel.state.members).filter(
+        (member) => member.user?.id !== loggedInUserId,
+      )
+    : [];
+  const member = otherMembers.length === 1 ? otherMembers[0] : undefined;
 
   return (
     <View style={[styles.container, {paddingBottom: tabbarHeight}]}>
-- 
cgit v1.2.3-70-g09d2

