Skip to content

Commit 7254bb6

Browse files
authored
fix: ui issue when customizing unread count when there is no count (#2180)
* fix: ui issue when customizing unread count when there is no count * fix: ui issue when customizing unread count when there is no count
1 parent 53d29c2 commit 7254bb6

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

package/src/components/ChannelPreview/ChannelPreviewUnreadCount.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
77

88
import type { DefaultStreamChatGenerics } from '../../types/types';
99

10-
const styles = StyleSheet.create({
11-
unreadContainer: {
12-
alignItems: 'center',
13-
borderRadius: 8,
14-
flexShrink: 1,
15-
justifyContent: 'center',
16-
},
17-
unreadText: {
18-
color: '#FFFFFF',
19-
fontSize: 11,
20-
fontWeight: '700',
21-
paddingHorizontal: 5,
22-
paddingVertical: 1,
23-
},
24-
});
25-
2610
export type ChannelPreviewUnreadCountProps<
2711
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
2812
> = Pick<ChannelPreviewProps<StreamChatGenerics>, 'channel'> & {
@@ -43,13 +27,29 @@ export const ChannelPreviewUnreadCount = <
4327
},
4428
} = useTheme();
4529

30+
if (!unread) return null;
31+
4632
return (
4733
<View style={[styles.unreadContainer, { backgroundColor: accent_red }, unreadContainer]}>
48-
{!!unread && (
49-
<Text numberOfLines={1} style={[styles.unreadText, unreadText]}>
50-
{unread > maxUnreadCount ? `${maxUnreadCount}+` : unread}
51-
</Text>
52-
)}
34+
<Text numberOfLines={1} style={[styles.unreadText, unreadText]}>
35+
{unread > maxUnreadCount ? `${maxUnreadCount}+` : unread}
36+
</Text>
5337
</View>
5438
);
5539
};
40+
41+
const styles = StyleSheet.create({
42+
unreadContainer: {
43+
alignItems: 'center',
44+
borderRadius: 8,
45+
flexShrink: 1,
46+
justifyContent: 'center',
47+
},
48+
unreadText: {
49+
color: '#FFFFFF',
50+
fontSize: 11,
51+
fontWeight: '700',
52+
paddingHorizontal: 5,
53+
paddingVertical: 1,
54+
},
55+
});

0 commit comments

Comments
 (0)