Skip to content

Commit

Permalink
messages: show mention background color
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Dec 9, 2023
1 parent fc7308d commit fda6f69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/components/messaging/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ function Message({ message, header }: Props) {
...ContextMenus.Message(app, message, app.account),
]);

const guild = message.guild_id ? app.guilds.get(message.guild_id) : undefined;
const isEveryoneMentioned = "mention_everyone" in message && message.mention_everyone;
const isUserMentioned = "mentions" in message && message.mentions.some((mention) => mention.id === app.account!.id);
const isRoleMentioned =
guild &&
"mention_roles" in message &&
message.mention_roles.some((role) => guild.members.me?.roles.some((role) => role.id === role.id));

return (
<MessageBase header={header} onContextMenu={(e) => contextMenu.open2(e, contextMenuItems)}>
<MessageBase
header={header}
onContextMenu={(e) => contextMenu.open2(e, contextMenuItems)}
mention={isEveryoneMentioned || isUserMentioned || isRoleMentioned}
>
<MessageInfo>
{header ? (
<Avatar key={message.author.id} user={message.author} size={40} />
Expand Down
2 changes: 1 addition & 1 deletion src/stores/objects/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default class Message extends MessageBase {
this.tts = data.tts;
this.mention_everyone = data.mention_everyone;
this.mentions = data.mentions; // TODO: user object?
this.mention_roles = data.mention_roles;
this.mention_roles = (data.mention_roles as unknown as { id: Snowflake }[]).map((x) => x.id); // FIXME: oh god, who did this in the server smh
this.mention_channels = data.mention_channels;
this.attachments = data.attachments;
this.embeds = data.embeds;
Expand Down

0 comments on commit fda6f69

Please sign in to comment.