Skip to content

Commit 9650e6a

Browse files
committed
chore: simplify unread message rendering logic and update theme usage in GroupChannelMessageNewLine and UnreadMessagesFloating
1 parent 6ff8c0d commit 9650e6a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageNewLine.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ type Props = {
1212
const GroupChannelMessageNewLine = ({ shouldRenderNewLine }: Props) => {
1313
if (!shouldRenderNewLine) return null;
1414

15-
const { select, palette } = useUIKitTheme();
1615
const { STRINGS } = useLocalization();
16+
const { colors } = useUIKitTheme();
1717

1818
return (
1919
<View style={styles.container}>
20-
<Box backgroundColor={select({ light: palette.primary300, dark: palette.primary200 })} style={styles.line} />
21-
<Text caption3 color={select({ light: palette.primary300, dark: palette.primary200 })} style={styles.label}>
20+
<Box backgroundColor={colors.primary} style={styles.line} />
21+
<Text caption3 numberOfLines={1} color={colors.primary} style={styles.label}>
2222
{STRINGS.GROUP_CHANNEL.LIST_NEW_LINE}
2323
</Text>
24-
<Box backgroundColor={select({ light: palette.primary300, dark: palette.primary200 })} style={styles.line} />
24+
<Box backgroundColor={colors.primary} style={styles.line} />
2525
</View>
2626
);
2727
};

packages/uikit-react-native/src/components/GroupChannelMessageRenderer/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useMemo, useRef } from 'react';
1+
import React, { useContext, useEffect, useRef } from 'react';
22

33
import type { GroupChannelMessageProps, RegexTextPattern } from '@sendbird/uikit-react-native-foundation';
44
import {
@@ -312,9 +312,7 @@ const GroupChannelMessageRenderer: GroupChannelProps['Fragment']['renderMessage'
312312
}
313313
});
314314

315-
const shouldRenderNewLine = useMemo(() => {
316-
return sbOptions.uikit.groupChannel.channel.enableMarkAsUnread && isFirstUnreadMessage;
317-
}, [sbOptions.uikit.groupChannel.channel.enableMarkAsUnread, isFirstUnreadMessage]);
315+
const shouldRenderNewLine = sbOptions.uikit.groupChannel.channel.enableMarkAsUnread && isFirstUnreadMessage;
318316

319317
return (
320318
<Box paddingHorizontal={16} marginBottom={messageGap}>

packages/uikit-react-native/src/components/UnreadMessagesFloating.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type UnreadMessagesFloatingProps = {
1212
};
1313
const UnreadMessagesFloating = ({ unreadMessageCount, visible, onPressClose }: UnreadMessagesFloatingProps) => {
1414
const { STRINGS } = useLocalization();
15-
const { select, palette } = useUIKitTheme();
15+
const { select, palette, colors } = useUIKitTheme();
1616
if (unreadMessageCount <= 0 || !visible) return null;
1717
return (
1818
<View
@@ -21,7 +21,7 @@ const UnreadMessagesFloating = ({ unreadMessageCount, visible, onPressClose }: U
2121
{ backgroundColor: select({ dark: palette.background400, light: palette.background50 }) },
2222
]}
2323
>
24-
<Text body2 color={select({ dark: palette.onBackgroundDark02, light: palette.onBackgroundLight02 })}>
24+
<Text body2 color={colors.onBackground02}>
2525
{STRINGS.GROUP_CHANNEL.LIST_FLOATING_UNREAD_MSG(unreadMessageCount)}
2626
</Text>
2727
<TouchableOpacity onPress={onPressClose} style={{ marginLeft: 4 }}>

0 commit comments

Comments
 (0)