/* * 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 {useLingui} from '@lingui/react/macro'; import {ArrowBendUpLeftIcon} from '@phosphor-icons/react'; import {clsx} from 'clsx'; import {observer} from 'mobx-react-lite'; import React from 'react'; import {PreloadableUserPopout} from '~/components/channel/PreloadableUserPopout'; import {Avatar} from '~/components/uikit/Avatar'; import FocusRing from '~/components/uikit/FocusRing/FocusRing'; import {SafeMarkdown} from '~/lib/markdown'; import {MarkdownContext} from '~/lib/markdown/renderers'; import type {MessageRecord} from '~/records/MessageRecord'; import ChannelStore from '~/stores/ChannelStore'; import GuildMemberStore from '~/stores/GuildMemberStore'; import MessageReferenceStore, {MessageReferenceState} from '~/stores/MessageReferenceStore'; import UserSettingsStore from '~/stores/UserSettingsStore'; import markupStyles from '~/styles/Markup.module.css'; import styles from '~/styles/Message.module.css'; import {goToMessage} from '~/utils/MessageNavigator'; import * as NicknameUtils from '~/utils/NicknameUtils'; export const ReplyPreview = observer( ({message, channelId, animateEmoji}: {message: MessageRecord; channelId: string; animateEmoji: boolean}) => { const {t} = useLingui(); const {message: referencedMessage, state: messageState} = MessageReferenceStore.getMessageReference( message.messageReference?.channel_id ?? '', message.messageReference?.message_id ?? '', ); const guildId = ChannelStore.getChannel(channelId)!.guildId; const messageDisplayCompact = UserSettingsStore.getMessageDisplayCompact(); const jumpToRepliedMessage = React.useCallback(() => { if (message.messageReference?.message_id) { goToMessage(message.channelId, message.messageReference.message_id); } }, [message.channelId, message.messageReference]); if (!message.messageReference) return null; if (messageState !== MessageReferenceState.LOADED || !referencedMessage) { return (
); } return (
{!messageDisplayCompact ? ( ) : (
)} {message.mentions.some((mention) => mention.id === referencedMessage.author.id) && '@'} {NicknameUtils.getNickname(referencedMessage.author, guildId)}
); }, );