MCPcopy Create free account
hub / github.com/VadimNotJustDev/SignalClone / MessageReply

Function MessageReply

components/MessageReply/MessageReply.tsx:21–99  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

19const grey = "lightgrey";
20
21const MessageReply = (props) => {
22 const { message: propMessage } = props;
23
24 const [message, setMessage] = useState<MessageModel>(propMessage);
25
26 const [user, setUser] = useState<User | undefined>();
27 const [isMe, setIsMe] = useState<boolean | null>(null);
28 const [soundURI, setSoundURI] = useState<any>(null);
29
30 const { width } = useWindowDimensions();
31
32 useEffect(() => {
33 DataStore.query(User, message.userID).then(setUser);
34 }, []);
35
36 useEffect(() => {
37 setMessage(propMessage);
38 }, [propMessage]);
39
40 useEffect(() => {
41 if (message.audio) {
42 Storage.get(message.audio).then(setSoundURI);
43 }
44 }, [message]);
45
46 useEffect(() => {
47 const checkIfMe = async () => {
48 if (!user) {
49 return;
50 }
51 const authUser = await Auth.currentAuthenticatedUser();
52 setIsMe(user.id === authUser.attributes.sub);
53 };
54 checkIfMe();
55 }, [user]);
56
57 if (!user) {
58 return <ActivityIndicator />;
59 }
60
61 return (
62 <View
63 style={[
64 styles.container,
65 isMe ? styles.rightContainer : styles.leftContainer,
66 { width: soundURI ? "75%" : "auto" },
67 ]}
68 >
69 <View style={styles.row}>
70 {message.image && (
71 <View style={{ marginBottom: message.content ? 10 : 0 }}>
72 <S3Image
73 imgKey={message.image}
74 style={{ width: width * 0.65, aspectRatio: 4 / 3 }}
75 resizeMode="contain"
76 />
77 </View>
78 )}

Callers

nothing calls this directly

Calls 1

checkIfMeFunction · 0.70

Tested by

no test coverage detected