Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reactions (TY JUSTIN) #94

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading