fixed a bug with false emoji requests
This commit is contained in:
parent
157967c555
commit
d06422a711
@ -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<Props> = ({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
|
||||
|
||||
@ -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<Props, State> {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -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<Props, State> {
|
||||
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) {
|
||||
|
||||
@ -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<Props> = ({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));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user