Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

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

Hampusdd8ed6f20575
diff --git a/fluxer_app/src/features/lexical/composer/useLexicalAutocomplete.ts b/fluxer_app/src/features/lexical/composer/useLexicalAutocomplete.ts
index 9ecb49cd3..09c6004aa 100644
--- a/fluxer_app/src/features/lexical/composer/useLexicalAutocomplete.ts
+++ b/fluxer_app/src/features/lexical/composer/useLexicalAutocomplete.ts
@@ -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},