Chore: Clean ThreadDetails - TypeScript (#3924)
This commit is contained in:
parent
e1038af2f8
commit
e00580d84e
|
@ -41,7 +41,7 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IThreadDetails {
|
interface IThreadDetails {
|
||||||
item: Partial<TThreadModel>;
|
item: Pick<TThreadModel, 'tcount' | 'replies' | 'id'>;
|
||||||
user: {
|
user: {
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
@ -62,21 +62,21 @@ const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, style }: IT
|
||||||
replies = '+999';
|
replies = '+999';
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFollowing = item.replies?.find((u: any) => u === user?.id);
|
const isFollowing = item.replies?.find((u: string) => u === user?.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, style]}>
|
<View style={[styles.container, style]}>
|
||||||
<View style={styles.detailsContainer}>
|
<View style={styles.detailsContainer}>
|
||||||
<View style={styles.detailContainer}>
|
<View style={styles.detailContainer}>
|
||||||
<CustomIcon name='threads' size={24} color={themes[theme!].auxiliaryText} />
|
<CustomIcon name='threads' size={24} color={themes[theme].auxiliaryText} />
|
||||||
<Text style={[styles.detailText, { color: themes[theme!].auxiliaryText }]} numberOfLines={1}>
|
<Text style={[styles.detailText, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>
|
||||||
{count}
|
{count}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.detailContainer}>
|
<View style={styles.detailContainer}>
|
||||||
<CustomIcon name='user' size={24} color={themes[theme!].auxiliaryText} />
|
<CustomIcon name='user' size={24} color={themes[theme].auxiliaryText} />
|
||||||
<Text style={[styles.detailText, { color: themes[theme!].auxiliaryText }]} numberOfLines={1}>
|
<Text style={[styles.detailText, { color: themes[theme].auxiliaryText }]} numberOfLines={1}>
|
||||||
{replies}
|
{replies}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
@ -87,7 +87,7 @@ const ThreadDetails = ({ item, user, badgeColor, toggleFollowThread, style }: IT
|
||||||
<CustomIcon
|
<CustomIcon
|
||||||
size={24}
|
size={24}
|
||||||
name={isFollowing ? 'notification' : 'notification-disabled'}
|
name={isFollowing ? 'notification' : 'notification-disabled'}
|
||||||
color={themes[theme!].auxiliaryTintColor}
|
color={themes[theme].auxiliaryTintColor}
|
||||||
/>
|
/>
|
||||||
</Touchable>
|
</Touchable>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -70,7 +70,6 @@ const Item = ({ item, useRealName, user, badgeColor, onPress, toggleFollowThread
|
||||||
const username = (useRealName && item?.u?.name) || item?.u?.username;
|
const username = (useRealName && item?.u?.name) || item?.u?.username;
|
||||||
let time;
|
let time;
|
||||||
if (item?.ts) {
|
if (item?.ts) {
|
||||||
// @ts-ignore TODO: to be fixed after we unify our types
|
|
||||||
time = formatDateThreads(item.ts);
|
time = formatDateThreads(item.ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,15 +77,15 @@ const Item = ({ item, useRealName, user, badgeColor, onPress, toggleFollowThread
|
||||||
<Touchable
|
<Touchable
|
||||||
onPress={() => onPress(item)}
|
onPress={() => onPress(item)}
|
||||||
testID={`thread-messages-view-${item.msg}`}
|
testID={`thread-messages-view-${item.msg}`}
|
||||||
style={{ backgroundColor: themes[theme!].backgroundColor }}>
|
style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Avatar style={styles.avatar} text={item?.u?.username} size={36} borderRadius={4} theme={theme} />
|
<Avatar style={styles.avatar} text={item?.u?.username} size={36} borderRadius={4} theme={theme} />
|
||||||
<View style={styles.contentContainer}>
|
<View style={styles.contentContainer}>
|
||||||
<View style={styles.titleContainer}>
|
<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}
|
{username}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[styles.time, { color: themes[theme!].auxiliaryText }]}>{time}</Text>
|
<Text style={[styles.time, { color: themes[theme].auxiliaryText }]}>{time}</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.messageContainer}>
|
<View style={styles.messageContainer}>
|
||||||
<MarkdownPreview msg={makeThreadName(item)} numberOfLines={2} style={[styles.markdown]} />
|
<MarkdownPreview msg={makeThreadName(item)} numberOfLines={2} style={[styles.markdown]} />
|
||||||
|
|
Loading…
Reference in New Issue