fix(app): react at once when picking a +: autocomplete emoji (#3010)

This commit is contained in:
Hampus
2026-09-28 12:30:45 +02:00
committed by GitHub
parent ed8c412415
commit dd8ed6f205
@@ -57,6 +57,8 @@ import type {GuildMember} from '@app/features/member/models/GuildMember';
import GuildMembers from '@app/features/member/state/GuildMembers';
import type {SearchContext} from '@app/features/member/state/MemberSearch';
import * as HighlightCommands from '@app/features/messaging/commands/HighlightCommands';
import * as MessageCommands from '@app/features/messaging/commands/MessageCommands';
import * as ReactionCommands from '@app/features/messaging/commands/ReactionCommands';
import Messages from '@app/features/messaging/state/MessagingMessages';
import {
filterAutocompleteMediaOptions,
@@ -75,7 +77,11 @@ import {
SPECIAL_MENTIONS,
} from '@app/features/messaging/utils/AutocompleteOptionBuilders';
import {isAutocompleteTriggerAllowed, type TriggerType} from '@app/features/messaging/utils/AutocompleteTriggerPolicy';
import {getReactionShortcodeName} from '@app/features/messaging/utils/ReactionShorthandUtils';
import {toReactionEmoji} from '@app/features/messaging/utils/MessageReactionUtils';
import {
getReactionShortcodeName,
getReactionShorthandTargetId,
} from '@app/features/messaging/utils/ReactionShorthandUtils';
import {
type AutocompleteTrigger,
detectAutocompleteTrigger,
@@ -703,6 +709,13 @@ export function useLexicalAutocomplete({
const caret = currentTextUpToCursor.length;
const matchStart = getComposerAutocompleteReplacementStart(currentTextUpToCursor, trigger.type, trigger.match);
if (trigger.type === 'emojiReaction' && isEmoji(option)) {
const targetId = channel == null ? null : getReactionShorthandTargetId(channel.id);
if (channel != null && targetId !== null) {
ReactionCommands.addReaction(i18n, channel.id, targetId, toReactionEmoji(option.emoji));
MessageCommands.stopReply(channel.id);
handle.clear();
return;
}
applyComposerReplacement(
handle,
{start: matchStart, end: caret},