Fix emoji picker

This commit is contained in:
Diego Mello 2022-12-08 10:51:37 -03:00
parent 2683976d21
commit e6ec8b4e39
3 changed files with 18 additions and 14 deletions

View File

@ -14,12 +14,12 @@ import { IEmoji, TAnyMessage } from '../../definitions';
import Touch from '../Touch';
export interface IHeader {
handleReaction: (emoji: IEmoji, message: TAnyMessage) => void;
handleReaction: (emoji: IEmoji | null, message: TAnyMessage) => void;
message: TAnyMessage;
isMasterDetail: boolean;
}
type TOnReaction = ({ emoji }: { emoji: IEmoji }) => void;
type TOnReaction = ({ emoji }: { emoji?: IEmoji }) => void;
interface THeaderItem {
item: IEmoji;
@ -94,8 +94,10 @@ const Header = React.memo(({ handleReaction, message, isMasterDetail }: IHeader)
const quantity = Math.trunc(size / (ITEM_SIZE + ITEM_MARGIN * 2) - 1);
const onReaction: TOnReaction = ({ emoji }) => {
handleReaction(emoji, message);
addFrequentlyUsed(emoji);
handleReaction(emoji || null, message);
if (emoji) {
addFrequentlyUsed(emoji);
}
};
const renderItem = ({ item }: { item: IEmoji }) => <HeaderItem item={item} onReaction={onReaction} theme={theme} />;

View File

@ -286,10 +286,10 @@ const MessageActions = React.memo(
}
};
const handleReaction: IHeader['handleReaction'] = (shortname, message) => {
const handleReaction: IHeader['handleReaction'] = (emoji, message) => {
logEvent(events.ROOM_MSG_ACTION_REACTION);
if (shortname) {
onReactionPress(shortname, message.id);
if (emoji) {
onReactionPress(emoji, message.id);
} else {
setTimeout(() => reactionInit(message), ACTION_SHEET_ANIMATION_DURATION);
}

View File

@ -843,13 +843,15 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
showReactionPicker = () => {
const { showActionSheet } = this.props;
const { selectedMessage } = this.state;
showActionSheet({
children: (
<ReactionPicker message={selectedMessage} onEmojiSelected={this.onReactionPress} reactionClose={this.onReactionClose} />
),
snaps: [400],
enableContentPanningGesture: false
});
setTimeout(() => {
showActionSheet({
children: (
<ReactionPicker message={selectedMessage} onEmojiSelected={this.onReactionPress} reactionClose={this.onReactionClose} />
),
snaps: [400],
enableContentPanningGesture: false
});
}, 100);
};
onReactionInit = (message: TAnyMessage) => {