Changeset View
Changeset View
Standalone View
Standalone View
native/chat/composed-message.react.js
// @flow | // @flow | ||||
import Icon from '@expo/vector-icons/Feather.js'; | import Icon from '@expo/vector-icons/Feather.js'; | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { StyleSheet, View } from 'react-native'; | import { StyleSheet, View } from 'react-native'; | ||||
import Animated from 'react-native-reanimated'; | import Animated from 'react-native-reanimated'; | ||||
import { getAvatarForUser } from 'lib/shared/avatar-utils.js'; | |||||
import { createMessageReply } from 'lib/shared/message-utils.js'; | import { createMessageReply } from 'lib/shared/message-utils.js'; | ||||
import { assertComposableMessageType } from 'lib/types/message-types.js'; | import { assertComposableMessageType } from 'lib/types/message-types.js'; | ||||
import { | import { | ||||
clusterEndHeight, | clusterEndHeight, | ||||
composedMessageStyle, | composedMessageStyle, | ||||
avatarOffset, | avatarOffset, | ||||
} from './chat-constants.js'; | } from './chat-constants.js'; | ||||
import { useComposedMessageMaxWidth } from './composed-message-width.js'; | import { useComposedMessageMaxWidth } from './composed-message-width.js'; | ||||
import { FailedSend } from './failed-send.react.js'; | import { FailedSend } from './failed-send.react.js'; | ||||
import { InlineEngagement } from './inline-engagement.react.js'; | import { InlineEngagement } from './inline-engagement.react.js'; | ||||
import { MessageHeader } from './message-header.react.js'; | import { MessageHeader } from './message-header.react.js'; | ||||
import { useNavigateToSidebar } from './sidebar-navigation.js'; | import { useNavigateToSidebar } from './sidebar-navigation.js'; | ||||
import SwipeableMessage from './swipeable-message.react.js'; | import SwipeableMessage from './swipeable-message.react.js'; | ||||
import { useContentAndHeaderOpacity, useDeliveryIconOpacity } from './utils.js'; | import { useContentAndHeaderOpacity, useDeliveryIconOpacity } from './utils.js'; | ||||
import Avatar from '../components/avatar.react.js'; | import UserAvatar from '../components/user-avatar.react.js'; | ||||
import { type InputState, InputStateContext } from '../input/input-state.js'; | import { type InputState, InputStateContext } from '../input/input-state.js'; | ||||
import { type Colors, useColors } from '../themes/colors.js'; | import { type Colors, useColors } from '../themes/colors.js'; | ||||
import type { ChatMessageInfoItemWithHeight } from '../types/chat-types.js'; | import type { ChatMessageInfoItemWithHeight } from '../types/chat-types.js'; | ||||
import { type AnimatedStyleObj, AnimatedView } from '../types/styles.js'; | import { type AnimatedStyleObj, AnimatedView } from '../types/styles.js'; | ||||
import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; | import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; | ||||
/* eslint-disable import/no-named-as-default-member */ | /* eslint-disable import/no-named-as-default-member */ | ||||
const { Node } = Animated; | const { Node } = Animated; | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | const triggerReply = | ||||
: undefined; | : undefined; | ||||
const triggerSidebar = | const triggerSidebar = | ||||
swipeOptions === 'sidebar' || swipeOptions === 'both' | swipeOptions === 'sidebar' || swipeOptions === 'both' | ||||
? navigateToSidebar | ? navigateToSidebar | ||||
: undefined; | : undefined; | ||||
let avatar; | let avatar; | ||||
if (!isViewer && item.endsCluster && shouldRenderAvatars) { | if (!isViewer && item.endsCluster && shouldRenderAvatars) { | ||||
const avatarInfo = getAvatarForUser(item.messageInfo.creator); | |||||
avatar = ( | avatar = ( | ||||
<View style={styles.avatarContainer}> | <View style={styles.avatarContainer}> | ||||
<Avatar size="small" avatarInfo={avatarInfo} /> | <UserAvatar size="small" userID={item.messageInfo.creator.id} /> | ||||
</View> | </View> | ||||
); | ); | ||||
} else if (!isViewer && shouldRenderAvatars) { | } else if (!isViewer && shouldRenderAvatars) { | ||||
avatar = <View style={styles.avatarOffset} />; | avatar = <View style={styles.avatarOffset} />; | ||||
} | } | ||||
const messageBox = ( | const messageBox = ( | ||||
<View style={messageBoxStyleContainerStyle}> | <View style={messageBoxStyleContainerStyle}> | ||||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |