@@ -22,7 +22,7 @@ import { Button } from '../../ui/';
2222
2323export type GiphyPropsWithContext = Pick <
2424 MessageContextValue ,
25- 'handleAction' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
25+ 'handleAction' | 'isMyMessage' | ' onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
2626> &
2727 Pick < MessagesContextValue , 'additionalPressableProps' | 'giphyVersion' > & {
2828 attachment : Attachment ;
@@ -34,6 +34,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
3434 attachment,
3535 giphyVersion,
3636 handleAction,
37+ isMyMessage,
3738 onLongPress,
3839 onPress,
3940 onPressIn,
@@ -53,7 +54,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
5354 } ,
5455 } = useTheme ( ) ;
5556
56- const styles = useStyles ( ) ;
57+ const styles = useStyles ( { isMyMessage } ) ;
5758
5859 const uri = image_url || thumb_url ;
5960
@@ -122,7 +123,7 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
122123 }
123124 } }
124125 testID = 'giphy-attachment'
125- style = { styles . container }
126+ style = { [ styles . container , container ] }
126127 { ...additionalPressableProps }
127128 >
128129 < GiphyImage attachment = { attachment } giphyVersion = { giphyVersion } />
@@ -134,10 +135,12 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
134135 const {
135136 attachment : { actions : prevActions , image_url : prevImageUrl , thumb_url : prevThumbUrl } ,
136137 giphyVersion : prevGiphyVersion ,
138+ isMyMessage : prevIsMyMessage ,
137139 } = prevProps ;
138140 const {
139141 attachment : { actions : nextActions , image_url : nextImageUrl , thumb_url : nextThumbUrl } ,
140142 giphyVersion : nextGiphyVersion ,
143+ isMyMessage : nextIsMyMessage ,
141144 } = nextProps ;
142145
143146 const imageUrlEqual = prevImageUrl === nextImageUrl ;
@@ -165,6 +168,11 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
165168 return false ;
166169 }
167170
171+ const isMyMessageEqual = prevIsMyMessage === nextIsMyMessage ;
172+ if ( ! isMyMessageEqual ) {
173+ return false ;
174+ }
175+
168176 return true ;
169177} ;
170178
@@ -178,7 +186,8 @@ export type GiphyProps = Partial<GiphyPropsWithContext> & {
178186 * UI component for card in attachments.
179187 */
180188export const Giphy = ( props : GiphyProps ) => {
181- const { handleAction, onLongPress, onPress, onPressIn, preventPress } = useMessageContext ( ) ;
189+ const { handleAction, isMyMessage, onLongPress, onPress, onPressIn, preventPress } =
190+ useMessageContext ( ) ;
182191 const { additionalPressableProps, giphyVersion } = useMessagesContext ( ) ;
183192
184193 return (
@@ -187,6 +196,7 @@ export const Giphy = (props: GiphyProps) => {
187196 additionalPressableProps,
188197 giphyVersion,
189198 handleAction,
199+ isMyMessage,
190200 onLongPress,
191201 onPress,
192202 onPressIn,
@@ -199,14 +209,16 @@ export const Giphy = (props: GiphyProps) => {
199209
200210Giphy . displayName = 'Giphy{messageItemView{giphy}}' ;
201211
202- const useStyles = ( ) => {
212+ const useStyles = ( { isMyMessage } : Pick < GiphyPropsWithContext , 'isMyMessage' > ) => {
203213 const {
204214 theme : { semantics } ,
205215 } = useTheme ( ) ;
206216 return useMemo ( ( ) => {
207217 return StyleSheet . create ( {
208218 container : {
209- backgroundColor : semantics . chatBgOutgoing ,
219+ backgroundColor : isMyMessage
220+ ? semantics . chatBgAttachmentOutgoing
221+ : semantics . chatBgAttachmentIncoming ,
210222 borderRadius : primitives . radiusLg ,
211223 maxWidth : 256 , // TODO: Not sure how to fix this
212224 overflow : 'hidden' ,
@@ -240,5 +252,5 @@ const useStyles = () => {
240252 lineHeight : primitives . typographyLineHeightTight ,
241253 } ,
242254 } ) ;
243- } , [ semantics ] ) ;
255+ } , [ isMyMessage , semantics ] ) ;
244256} ;
0 commit comments