/* eslint-disable @typescript-eslint/no-non-null-assertion */ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import { CustomIcon } from '../lib/Icons'; import { themes } from '../constants/colors'; import sharedStyles from '../views/Styles'; import { withTheme } from '../theme'; const styles = StyleSheet.create({ container: { flex: 1, flexDirection: 'row', alignItems: 'center' }, detailsContainer: { flex: 1, flexDirection: 'row' }, detailContainer: { flexDirection: 'row', alignItems: 'center', marginRight: 8 }, detailText: { fontSize: 10, marginLeft: 2, ...sharedStyles.textSemibold }, badgeContainer: { flexDirection: 'row', alignItems: 'center' }, badge: { width: 8, height: 8, borderRadius: 4, marginRight: 8 } }); interface IThreadDetails { item: { tcount?: number | string; dcount?: number | string; replies?: any; id: string; }; user: { id: string; }; badgeColor: string; toggleFollowThread: Function; thread: boolean; time: string; style: object; theme: string; } const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, thread, time, style, theme }: IThreadDetails) => { const { tcount, dcount } = item; let count = tcount || dcount; if (count! >= 1000) { count = '+999'; } else if (count! >= 100) { count = '+99'; } let replies = item?.replies?.length ?? 0; if (replies >= 1000) { replies = '+999'; } else if (replies >= 100) { replies = '+99'; } const isFollowing = item.replies?.find((u: any) => u === user?.id); return ( {count} {thread ? replies : time} {thread ? ( {badgeColor ? : null} toggleFollowThread?.(isFollowing, item.id)}> ) : null} ); }; export default withTheme(ThreadDetails);