@@ -234,17 +234,47 @@ const MessageContentWithContext = <
234234
235235 const isBorderColor = isMyMessage && ! error ;
236236
237- const isLastMessageInMessageGroup = ( firstGroupStyle : string , secondGroupStyle : string ) =>
238- ( groupStyle === firstGroupStyle || groupStyle === secondGroupStyle ) &&
239- ( ! hasThreadReplies || threadList ) ;
237+ const getBorderRadius = ( ) => {
238+ // enum('top', 'middle', 'bottom', 'single')
239+ const groupPosition = groupStyles ?. [ 0 ] ;
240+
241+ const isBottomOrSingle = groupPosition === 'single' || groupPosition === 'bottom' ;
242+ let borderBottomLeftRadius = borderRadiusL ;
243+ let borderBottomRightRadius = borderRadiusL ;
244+
245+ if ( isBottomOrSingle && ( ! hasThreadReplies || threadList ) ) {
246+ // add relevant sharp corner
247+ if ( alignment === 'left' ) {
248+ borderBottomLeftRadius = borderRadiusS ;
249+ } else {
250+ borderBottomRightRadius = borderRadiusS ;
251+ }
252+ }
240253
241- const calculateBorderRadius = ( firstGroupStyle : string , secondGroupStyle : string ) =>
242- isLastMessageInMessageGroup ( firstGroupStyle , secondGroupStyle ) ? borderRadiusS : borderRadiusL ;
254+ return {
255+ borderBottomLeftRadius,
256+ borderBottomRightRadius,
257+ } ;
258+ } ;
243259
244- const getRadiusFromTheme = (
245- radius : number | undefined ,
246- defaultValue : number | undefined = borderRadiusL ,
247- ) => ( radius !== undefined ? radius : defaultValue ) ;
260+ const getBorderRadiusFromTheme = ( ) => {
261+ const bordersFromTheme : Record < string , number | undefined > = {
262+ borderBottomLeftRadius,
263+ borderBottomRightRadius,
264+ borderRadius,
265+ borderTopLeftRadius,
266+ borderTopRightRadius,
267+ } ;
268+
269+ // filter out undefined values
270+ for ( const key in bordersFromTheme ) {
271+ if ( bordersFromTheme [ key ] === undefined ) {
272+ delete bordersFromTheme [ key ] ;
273+ }
274+ }
275+
276+ return bordersFromTheme ;
277+ } ;
248278
249279 return (
250280 < TouchableOpacity
@@ -320,18 +350,9 @@ const MessageContentWithContext = <
320350 styles . containerInner ,
321351 {
322352 backgroundColor,
323- borderBottomLeftRadius : getRadiusFromTheme (
324- borderBottomLeftRadius ,
325- calculateBorderRadius ( 'left_bottom' , 'left_single' ) ,
326- ) ,
327- borderBottomRightRadius : getRadiusFromTheme (
328- borderBottomRightRadius ,
329- calculateBorderRadius ( 'right_bottom' , 'right_single' ) ,
330- ) ,
331353 borderColor : isBorderColor ? backgroundColor : grey_whisper ,
332- borderRadius,
333- borderTopLeftRadius : getRadiusFromTheme ( borderTopLeftRadius ) ,
334- borderTopRightRadius : getRadiusFromTheme ( borderTopRightRadius ) ,
354+ ...getBorderRadius ( ) ,
355+ ...getBorderRadiusFromTheme ( ) ,
335356 } ,
336357 noBorder ? { borderWidth : 0 } : { } ,
337358 containerInner ,
0 commit comments