Include @ symbol when reply is a mention.

This commit is contained in:
Paul 2021-08-16 18:08:44 +01:00
parent b4f16f0d00
commit 1f2e58b10e
3 changed files with 95 additions and 81 deletions

View file

@ -81,6 +81,7 @@ const Message = observer(
index={index} index={index}
id={message_id} id={message_id}
channel={message.channel!} channel={message.channel!}
parent_mentions={message.mention_ids ?? []}
/> />
))} ))}
<MessageBase <MessageBase

View file

@ -18,6 +18,7 @@ import UserShort from "../../user/UserShort";
import { SystemMessage } from "../SystemMessage"; import { SystemMessage } from "../SystemMessage";
interface Props { interface Props {
parent_mentions: string[];
channel: Channel; channel: Channel;
index: number; index: number;
id: string; id: string;
@ -33,7 +34,6 @@ export const ReplyBase = styled.div<{
display: flex; display: flex;
margin-inline-start: 30px; margin-inline-start: 30px;
margin-inline-end: 12px; margin-inline-end: 12px;
/*margin-bottom: 4px;*/
font-size: 0.8em; font-size: 0.8em;
user-select: none; user-select: none;
align-items: center; align-items: center;
@ -137,7 +137,8 @@ export const ReplyBase = styled.div<{
`} `}
`; `;
export const MessageReply = observer(({ index, channel, id }: Props) => { export const MessageReply = observer(
({ index, channel, id, parent_mentions }: Props) => {
const view = getRenderer(channel); const view = getRenderer(channel);
if (view.state !== "RENDER") return null; if (view.state !== "RENDER") return null;
@ -181,6 +182,9 @@ export const MessageReply = observer(({ index, channel, id }: Props) => {
user={message.author} user={message.author}
size={16} size={16}
showServerIdentity showServerIdentity
prefixAt={parent_mentions.includes(
message.author_id,
)}
/> />
</div> </div>
<div <div
@ -188,7 +192,8 @@ export const MessageReply = observer(({ index, channel, id }: Props) => {
onClick={() => { onClick={() => {
const channel = message.channel!; const channel = message.channel!;
if ( if (
channel.channel_type === "TextChannel" channel.channel_type ===
"TextChannel"
) { ) {
history.push( history.push(
`/server/${channel.server_id}/channel/${channel._id}/${message._id}`, `/server/${channel.server_id}/channel/${channel._id}/${message._id}`,
@ -203,7 +208,8 @@ export const MessageReply = observer(({ index, channel, id }: Props) => {
<> <>
<File size={16} /> <File size={16} />
<em> <em>
{message.attachments.length > 1 ? ( {message.attachments.length >
1 ? (
<Text id="app.main.channel.misc.sent_multiple_files" /> <Text id="app.main.channel.misc.sent_multiple_files" />
) : ( ) : (
<Text id="app.main.channel.misc.sent_file" /> <Text id="app.main.channel.misc.sent_file" />
@ -224,4 +230,5 @@ export const MessageReply = observer(({ index, channel, id }: Props) => {
)} )}
</ReplyBase> </ReplyBase>
); );
}); },
);

View file

@ -28,10 +28,12 @@ const BotBadge = styled.div`
export const Username = observer( export const Username = observer(
({ ({
user, user,
prefixAt,
showServerIdentity, showServerIdentity,
...otherProps ...otherProps
}: { }: {
user?: User; user?: User;
prefixAt?: boolean;
showServerIdentity?: boolean; showServerIdentity?: boolean;
} & JSX.HTMLAttributes<HTMLElement>) => { } & JSX.HTMLAttributes<HTMLElement>) => {
let username = user?.username; let username = user?.username;
@ -84,6 +86,7 @@ export const Username = observer(
return ( return (
<span {...otherProps} style={{ color }}> <span {...otherProps} style={{ color }}>
{prefixAt ? "@" : undefined}
{username ?? <Text id="app.main.channel.unknown_user" />} {username ?? <Text id="app.main.channel.unknown_user" />}
</span> </span>
); );
@ -93,10 +96,12 @@ export const Username = observer(
export default function UserShort({ export default function UserShort({
user, user,
size, size,
prefixAt,
showServerIdentity, showServerIdentity,
}: { }: {
user?: User; user?: User;
size?: number; size?: number;
prefixAt?: boolean;
showServerIdentity?: boolean; showServerIdentity?: boolean;
}) { }) {
const { openScreen } = useIntermediate(); const { openScreen } = useIntermediate();
@ -115,6 +120,7 @@ export default function UserShort({
user={user} user={user}
showServerIdentity={showServerIdentity} showServerIdentity={showServerIdentity}
onClick={openProfile} onClick={openProfile}
prefixAt={prefixAt}
/> />
</> </>
); );