From 0dc9a8cc06ec8e0208989ceb007faad201d89f28 Mon Sep 17 00:00:00 2001
From: Shravya Ramesh <shravs1208@gmail.com>
Date: Wed, 14 Apr 2021 16:46:33 -0700
Subject: refactored

---
 src/components/messages/MessageAvatar.tsx | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 src/components/messages/MessageAvatar.tsx

(limited to 'src/components/messages/MessageAvatar.tsx')

diff --git a/src/components/messages/MessageAvatar.tsx b/src/components/messages/MessageAvatar.tsx
new file mode 100644
index 00000000..d275eae5
--- /dev/null
+++ b/src/components/messages/MessageAvatar.tsx
@@ -0,0 +1,44 @@
+import React, {useContext} from 'react';
+import {Image, StyleSheet, View} from 'react-native';
+import {getMember, normalize} from '../../utils';
+import {useMessageContext} from 'stream-chat-react-native-core';
+import {useStore} from 'react-redux';
+import {ChatContext} from '../../App';
+
+const MessageAvatar: React.FC = () => {
+  const {channel} = useContext(ChatContext);
+  const state = useStore().getState();
+  const member = getMember(channel, state);
+  const message = useMessageContext();
+
+  return (
+    <View style={styles.messageAvatarContainer}>
+      {message.lastGroupMessage === true && (
+        <Image
+          style={styles.messageAvatar}
+          source={
+            member
+              ? {uri: member.user?.thumbnail_url}
+              : require('../../assets/images/avatar-placeholder.png')
+          }
+        />
+      )}
+    </View>
+  );
+};
+
+const styles = StyleSheet.create({
+  messageAvatarContainer: {
+    width: normalize(20),
+    zIndex: 1,
+    bottom: 20,
+    marginRight: '2%',
+  },
+  messageAvatar: {
+    borderRadius: 50,
+    width: normalize(18),
+    height: normalize(18),
+  },
+});
+
+export default MessageAvatar;
-- 
cgit v1.2.3-70-g09d2

