Skip to content

Commit

Permalink
Fix reactions (TY JUSTIN) (#94)
Browse files Browse the repository at this point in the history
* Fix reactions (TY JUSTIN)

* Remove logs
  • Loading branch information
adityapawar1 authored Apr 22, 2024
1 parent 3b01e9d commit a3f3530
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/ReactionDisplay/ReactionDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import Emoji from 'react-native-emoji';
import globalStyles from '../../styles/globalStyles';

type ReactionDisplayProps = {
reactions: string[];
reactions: (string | null)[];
};

function ReactionDisplay({ reactions }: ReactionDisplayProps) {
const cleanedReactions = reactions.filter(reaction => reaction !== null);
const reactionColors: Record<string, string> = {
heart: '#FFCCCB',
clap: '#FFD580',
Expand All @@ -16,7 +17,7 @@ function ReactionDisplay({ reactions }: ReactionDisplayProps) {
muscle: '#eddcf7',
};
const defaultColor = reactionColors['heart'];
const setOfReactions = [...reactions];
const setOfReactions = [...cleanedReactions];
setOfReactions.push('heart');
setOfReactions.push('clap');
setOfReactions.push('muscle');
Expand All @@ -31,6 +32,8 @@ function ReactionDisplay({ reactions }: ReactionDisplayProps) {
}}
>
{reactionDisplay.map(reaction => {
if (reaction === null) return;

return (
<View
key={reaction}
Expand All @@ -50,7 +53,7 @@ function ReactionDisplay({ reactions }: ReactionDisplayProps) {
})}
<View style={styles.reactionNumber}>
<Text style={[globalStyles.subtext, styles.reactionText]}>
{reactions?.length ?? 0}
{cleanedReactions?.length ?? 0}
</Text>
</View>
</View>
Expand Down

0 comments on commit a3f3530

Please sign in to comment.