/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see .
*/
import * as MessageActionCreators from '@app/actions/MessageActionCreators';
import styles from '@app/components/channel/ReplyBar.module.css';
import wrapperStyles from '@app/components/channel/textarea/InputWrapper.module.css';
import FocusRing from '@app/components/uikit/focus_ring/FocusRing';
import {Tooltip} from '@app/components/uikit/tooltip/Tooltip';
import type {ChannelRecord} from '@app/records/ChannelRecord';
import type {MessageRecord} from '@app/records/MessageRecord';
import AuthenticationStore from '@app/stores/AuthenticationStore';
import GuildStore from '@app/stores/GuildStore';
import * as NicknameUtils from '@app/utils/NicknameUtils';
import {Trans, useLingui} from '@lingui/react/macro';
import {AtIcon, XCircleIcon} from '@phosphor-icons/react';
import {clsx} from 'clsx';
import {observer} from 'mobx-react-lite';
interface ReplyBarProps {
replyingMessageObject: MessageRecord;
shouldReplyMention: boolean;
setShouldReplyMention: (mentioning: boolean) => void;
channel: ChannelRecord;
}
export const ReplyBar = observer(function ReplyBar({
replyingMessageObject,
shouldReplyMention: initialShouldMention,
setShouldReplyMention,
channel,
}: ReplyBarProps) {
const {t} = useLingui();
const guild = GuildStore.getGuild(channel.guildId ?? '');
const currentUserId = AuthenticationStore.currentUserId;
const isOwnMessage = replyingMessageObject.author.id === currentUserId;
const isInGuild = channel.guildId != null;
const isWebhook = replyingMessageObject.webhookId != null;
const canMention = !isOwnMessage && isInGuild && !isWebhook;
const shouldMention = initialShouldMention && canMention;
const authorNickname = NicknameUtils.getNickname(replyingMessageObject.author, guild?.id);
const handleStopReply = () => {
MessageActionCreators.stopReply(channel.id);
};
const toggleMention = () => {
setShouldReplyMention(!shouldMention);
};
const handleKeyDown = (handler: () => void) => (event: React.KeyboardEvent) => {
if (event.key === 'Enter') handler();
};
return (