Chore: Clean ThreadDetails - TypeScript (#3924)

This commit is contained in:
Alex Junior 2022-03-22 11:16:41 -03:00 committed by GitHub
parent e1038af2f8
commit e00580d84e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -41,7 +41,7 @@ const styles = StyleSheet.create({
});
interface IThreadDetails {
item: Partial<TThreadModel>;
item: Pick<TThreadModel, 'tcount' | 'replies' | 'id'>;
user: {
id: string;
};
@ -62,21 +62,21 @@ const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, style }: IT
replies = '+999';
}
const isFollowing = item.replies?.find((u: any) => u === user?.id);
const isFollowing = item.replies?.find((u: string) => u === user?.id);
return (
<View style={[styles.container, style]}>
<View style={styles.detailsContainer}>
<View style={styles.detailContainer}>
<CustomIcon name='threads' size={24} color={themes[theme!].auxiliaryText} />
<Text style={[styles.detailText, { color: themes[theme!].auxiliaryText }]} numberOfLines={1}>
<CustomIcon name='threads' size={24} color={themes[theme].auxiliaryText} />
<Text style={[styles.detailText, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>
{count}
</Text>
</View>
<View style={styles.detailContainer}>
<CustomIcon name='user' size={24} color={themes[theme!].auxiliaryText} />
<Text style={[styles.detailText, { color: themes[theme!].auxiliaryText }]} numberOfLines={1}>
<CustomIcon name='user' size={24} color={themes[theme].auxiliaryText} />
<Text style={[styles.detailText, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>
{replies}
</Text>
</View>
@ -87,7 +87,7 @@ const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, style }: IT
<CustomIcon
size={24}
name={isFollowing ? 'notification' : 'notification-disabled'}
color={themes[theme!].auxiliaryTintColor}
color={themes[theme].auxiliaryTintColor}
/>
</Touchable>
</View>

View File

@ -70,7 +70,6 @@ const Item = ({ item, useRealName, user, badgeColor, onPress, toggleFollowThread
const username = (useRealName && item?.u?.name) || item?.u?.username;
let time;
if (item?.ts) {
// @ts-ignore TODO: to be fixed after we unify our types
time = formatDateThreads(item.ts);
}
@ -78,15 +77,15 @@ const Item = ({ item, useRealName, user, badgeColor, onPress, toggleFollowThread
<Touchable
onPress={() => onPress(item)}
testID={`thread-messages-view-${item.msg}`}
style={{ backgroundColor: themes[theme!].backgroundColor }}>
style={{ backgroundColor: themes[theme].backgroundColor }}>
<View style={styles.container}>
<Avatar style={styles.avatar} text={item?.u?.username} size={36} borderRadius={4} theme={theme} />
<View style={styles.contentContainer}>
<View style={styles.titleContainer}>
<Text style={[styles.title, { color: themes[theme!].titleText }]} numberOfLines={1}>
<Text style={[styles.title, { color: themes[theme].titleText }]} numberOfLines={1}>
{username}
</Text>
<Text style={[styles.time, { color: themes[theme!].auxiliaryText }]}>{time}</Text>
<Text style={[styles.time, { color: themes[theme].auxiliaryText }]}>{time}</Text>
</View>
<View style={styles.messageContainer}>
<MarkdownPreview msg={makeThreadName(item)} numberOfLines={2} style={[styles.markdown]} />