From d06422a711fc67504528eb64d9b98e62f8f02035 Mon Sep 17 00:00:00 2001 From: "dmitrii.pichenikin" Date: Thu, 12 Mar 2026 15:53:14 +0300 Subject: [PATCH] fixed a bug with false emoji requests --- webapp/src/components/rhs/all_badges.tsx | 4 ++-- webapp/src/components/rhs/badge_details.tsx | 8 ++++---- webapp/src/components/rhs/user_badges.tsx | 5 +++-- webapp/src/components/user_popover/badge_list.tsx | 6 ++++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/webapp/src/components/rhs/all_badges.tsx b/webapp/src/components/rhs/all_badges.tsx index 24dae12..78eeb5e 100644 --- a/webapp/src/components/rhs/all_badges.tsx +++ b/webapp/src/components/rhs/all_badges.tsx @@ -4,7 +4,7 @@ import {FormattedMessage} from 'react-intl'; import {Virtuoso} from 'react-virtuoso'; import {useSelector} from 'react-redux'; -import {systemEmojis} from 'mattermost-redux/actions/emojis'; +import {EmojiIndicesByAlias} from 'utils/emoji'; import {BadgeID, AllBadgesBadge} from '../../types/badges'; import Client from '../../client/api'; @@ -52,7 +52,7 @@ const AllBadges: React.FC = ({filterTypeId, filterTypeName, actions}) => names.push(badge.image); } }); - const toLoad = names.filter((v) => !systemEmojis.has(v)); + const toLoad = names.filter((v) => !EmojiIndicesByAlias.has(v)); actions.getCustomEmojisByName(toLoad); }); }, []); // eslint-disable-line react-hooks/exhaustive-deps diff --git a/webapp/src/components/rhs/badge_details.tsx b/webapp/src/components/rhs/badge_details.tsx index 585b057..be4a436 100644 --- a/webapp/src/components/rhs/badge_details.tsx +++ b/webapp/src/components/rhs/badge_details.tsx @@ -2,13 +2,13 @@ import React from 'react'; import {FormattedMessage} from 'react-intl'; -import {systemEmojis} from 'mattermost-redux/actions/emojis'; +import {EmojiIndicesByAlias} from 'utils/emoji'; import {BadgeDetails, BadgeID} from '../../types/badges'; import Client from '../../client/api'; import {RHSState} from '../../types/general'; -import {RHS_STATE_MY, RHS_STATE_OTHER, RHS_STATE_TYPES} from '../../constants'; +import {IMAGE_TYPE_EMOJI, RHS_STATE_MY, RHS_STATE_OTHER, RHS_STATE_TYPES} from '../../constants'; import BadgeImage from '../badge_image/badge_image'; import {markdown} from 'utils/markdown'; @@ -57,8 +57,8 @@ class BadgeDetailsComponent extends React.PureComponent { } componentDidUpdate(prevProps: Props, prevState: State) { - if (this.state.badge !== prevState.badge && this.state.badge && !systemEmojis.has(this.state.badge.name)) { - this.props.actions.getCustomEmojiByName(this.state.badge.name); + if (this.state.badge !== prevState.badge && this.state.badge && this.state.badge.image_type === IMAGE_TYPE_EMOJI && !EmojiIndicesByAlias.has(this.state.badge.image)) { + this.props.actions.getCustomEmojiByName(this.state.badge.image); } if (this.props.badgeID === prevProps.badgeID) { diff --git a/webapp/src/components/rhs/user_badges.tsx b/webapp/src/components/rhs/user_badges.tsx index 7a346b5..7cd40d8 100644 --- a/webapp/src/components/rhs/user_badges.tsx +++ b/webapp/src/components/rhs/user_badges.tsx @@ -3,7 +3,8 @@ import React from 'react'; import {FormattedMessage} from 'react-intl'; import {UserProfile} from 'mattermost-redux/types/users'; -import {systemEmojis} from 'mattermost-redux/actions/emojis'; + +import {EmojiIndicesByAlias} from 'utils/emoji'; import {BadgeID, UserBadge} from '../../types/badges'; import Client from '../../client/api'; @@ -59,7 +60,7 @@ class UserBadges extends React.PureComponent { names.push(badge.image); } }); - const toLoad = names.filter((v) => !systemEmojis.has(v)); + const toLoad = names.filter((v) => !EmojiIndicesByAlias.has(v)); this.props.actions.getCustomEmojisByName(toLoad); } if (this.props.user?.id === prevProps.user?.id) { diff --git a/webapp/src/components/user_popover/badge_list.tsx b/webapp/src/components/user_popover/badge_list.tsx index 981e22b..543ed1f 100644 --- a/webapp/src/components/user_popover/badge_list.tsx +++ b/webapp/src/components/user_popover/badge_list.tsx @@ -7,7 +7,9 @@ import {useDispatch, useSelector} from 'react-redux'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/common'; -import {systemEmojis, getCustomEmojisByName} from 'mattermost-redux/actions/emojis'; +import {getCustomEmojisByName} from 'mattermost-redux/actions/emojis'; + +import {EmojiIndicesByAlias} from 'utils/emoji'; import {UserBadge} from 'types/badges'; import Client from 'client/api'; @@ -58,7 +60,7 @@ const BadgeList: React.FC = ({user, hide}) => { const names = toShow. filter(({badge}) => badge.image_type === IMAGE_TYPE_EMOJI). map(({badge}) => badge.image). - filter((v) => !systemEmojis.has(v)); + filter((v) => !EmojiIndicesByAlias.has(v)); if (names.length > 0) { dispatch(getCustomEmojisByName(names)); }