Skip to content

Commit

Permalink
fix: use process reactions improvements for thread list
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Oct 25, 2024
1 parent 0759817 commit f093028
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions package/src/components/Message/hooks/useProcessReactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ const isOwnReaction = <
>(
reactionType: string,
ownReactions?: MessageReactionsData<StreamChatGenerics>['own_reactions'],
) => (ownReactions ? ownReactions.some((reaction) => reaction.type === reactionType) : false);
latestReactions?: ReactionResponse<StreamChatGenerics>[] | null,
userID?: string,
) =>
(ownReactions ? ownReactions.some((reaction) => reaction.type === reactionType) : false) ||
(latestReactions
? latestReactions.some(
(reaction) => reaction?.user?.id === userID && reaction.type === reactionType,
)
: false);

const isSupportedReaction = (reactionType: string, supportedReactions?: ReactionData[]) =>
supportedReactions
Expand Down Expand Up @@ -109,7 +117,12 @@ export const useProcessReactions = <
Icon: getEmojiByReactionType(reactionType, supportedReactions),
lastReactionAt: last_reaction_at ? new Date(last_reaction_at) : null,
latestReactedUserNames,
own: isOwnReaction<StreamChatGenerics>(reactionType, own_reactions),
own: isOwnReaction<StreamChatGenerics>(
reactionType,
own_reactions,
latest_reactions,
client.userID,
),
type: reactionType,
unlistedReactedUserCount: count - latestReactedUserNames.length,
};
Expand Down

0 comments on commit f093028

Please sign in to comment.