fix: reactor count was at most 4 even if hundrers reacted

pull/3206/head
Audric Ackermann 7 months ago
parent 151d2012ca
commit a56d0279fc

@ -62,22 +62,19 @@ const StyledEmoji = styled.span`
const generateContactsString = ( const generateContactsString = (
senders: Array<string> senders: Array<string>
): { contacts: Array<string>; numberOfReactors: number; hasMe: boolean } => { ): { contacts: Array<string>; hasMe: boolean } => {
const contacts: Array<string> = []; const contacts: Array<string> = [];
let hasMe = false; let hasMe = false;
let numberOfReactors = 0;
senders.forEach(sender => { senders.forEach(sender => {
// TODO truncate with ellipsis if too long? // TODO truncate with ellipsis if too long?
const contact = findAndFormatContact(sender); const contact = findAndFormatContact(sender);
if (contact.isMe) { if (contact.isMe) {
hasMe = true; hasMe = true;
numberOfReactors++;
} else { } else {
contacts.push(contact?.profileName ?? contact?.name ?? PubKey.shorten(sender)); contacts.push(contact?.profileName ?? contact?.name ?? PubKey.shorten(sender));
numberOfReactors++;
} }
}); });
return { contacts, hasMe, numberOfReactors }; return { contacts, hasMe };
}; };
const getI18nComponentProps = ( const getI18nComponentProps = (
@ -118,7 +115,7 @@ type Props = {
}; };
export const ReactionPopup = (props: Props) => { export const ReactionPopup = (props: Props) => {
const { emoji, senders, tooltipPosition = 'center', onClick } = props; const { emoji, senders, tooltipPosition = 'center', count, onClick } = props;
const { emojiName, emojiAriaLabel } = useMemo( const { emojiName, emojiAriaLabel } = useMemo(
() => ({ () => ({
@ -128,14 +125,11 @@ export const ReactionPopup = (props: Props) => {
[emoji] [emoji]
); );
const { contacts, hasMe, numberOfReactors } = useMemo( const { contacts, hasMe } = useMemo(() => generateContactsString(senders), [senders]);
() => generateContactsString(senders),
[senders]
);
const i18nProps = useMemo( const i18nProps = useMemo(
() => getI18nComponentProps(hasMe, contacts, numberOfReactors, emoji, emojiName), () => getI18nComponentProps(hasMe, contacts, count, emoji, emojiName),
[hasMe, contacts, numberOfReactors, emoji, emojiName] [hasMe, contacts, count, emoji, emojiName]
); );
return ( return (

Loading…
Cancel
Save