diff --git a/src/equicordplugins/messagePeek/index.tsx b/src/equicordplugins/messagePeek/index.tsx
index c329df787..f8d888c98 100644
--- a/src/equicordplugins/messagePeek/index.tsx
+++ b/src/equicordplugins/messagePeek/index.tsx
@@ -9,7 +9,7 @@ import "./style.css";
import { DecoratorProps } from "@api/MemberListDecorators";
import { isPluginEnabled } from "@api/PluginManager";
import betterActivities from "@equicordplugins/betterActivities";
-import { customNicknames } from "@plugins/showMeYourName";
+import showMeYourName from "@plugins/showMeYourName";
import { Devs, EquicordDevs } from "@utils/constants";
import { classNameFactory } from "@utils/css";
import { classes } from "@utils/misc";
@@ -140,7 +140,7 @@ function getMessageContent(message: Message): MessageContent | null {
return null;
}
-function MessagePreviewContent({ channel }: { channel: Channel; }) {
+function MessagePreviewContent({ channel, user }: { channel: Channel; user: User | null | undefined; }) {
const lastMessage = useStateFromStores(
[MessageStore],
() => MessageStore.getLastMessage(channel.id) as Message | undefined
@@ -154,6 +154,8 @@ function MessagePreviewContent({ channel }: { channel: Channel; }) {
return <>{channel.recipients.length + 1} Members>;
}
+ const smynName = (isPluginEnabled(showMeYourName.name) && showMeYourName.getMemberListProfilesReactionsVoiceNameText({ user: user ?? lastMessage?.author, type: "membersList" }));
+
if (!lastMessage) return null;
const content = getMessageContent(lastMessage);
@@ -161,7 +163,7 @@ function MessagePreviewContent({ channel }: { channel: Channel; }) {
const currentUserId = UserStore.getCurrentUser()?.id;
const isOwnMessage = lastMessage.author.id === currentUserId;
- const authorName = isOwnMessage ? "You" : (RelationshipStore.getNickname(lastMessage.author.id) ?? customNicknames[lastMessage.author.id] ?? lastMessage.author.globalName ?? lastMessage.author.username);
+ const authorName = isOwnMessage ? "You" : (smynName ?? RelationshipStore.getNickname(lastMessage.author.id) ?? lastMessage.author.globalName ?? lastMessage.author.username);
const Icon = content.icon ? Icons[content.icon] : null;
return (
@@ -194,7 +196,7 @@ function SubText({ channel, user, activities, applicationStream, voiceChannel, s
return (
@@ -203,7 +205,7 @@ function SubText({ channel, user, activities, applicationStream, voiceChannel, s
return (
-
+
);
}
diff --git a/src/plugins/showMeYourName/index.tsx b/src/plugins/showMeYourName/index.tsx
index e433607dc..ee0af0332 100644
--- a/src/plugins/showMeYourName/index.tsx
+++ b/src/plugins/showMeYourName/index.tsx
@@ -288,14 +288,14 @@ interface mentionProps {
}
interface messageProps {
- message: Message;
+ message: Message | null | undefined;
userOverride?: User;
isRepliedMessage?: boolean;
withMentionPrefix?: boolean;
}
interface memberListProfileReactionProps {
- user: User;
+ user: User | null | undefined;
type: "membersList" | "profilesPopout" | "profilesTooltip" | "reactionsTooltip" | "reactionsPopout" | "voiceChannel";
guildId?: string;
tags?: any;
@@ -308,7 +308,7 @@ function getMemberListProfilesReactionsVoiceName(
// props.guildId for member list & preview profile, props.tags.props.displayProfile.guildId
// for full guild profile and main profile, which is indicated by whether it is null or not.
const guildId = props.guildId || props.tags?.props?.displayProfile?.guildId || null;
- const member = guildId ? GuildMemberStore.getMember(guildId, user.id) : null;
+ const member = guildId && user ? GuildMemberStore.getMember(guildId, user.id) : null;
const author = user && member ? { ...user, ...member } : user || member || null;
const shouldHookless = type === "reactionsTooltip" || type === "profilesTooltip";
return renderUsername(author, null, null, type, "", shouldHookless);
@@ -325,14 +325,14 @@ function getMemberListProfilesReactionsVoiceNameElement(props: memberListProfile
function getMessageName(props: messageProps): [string | null, JSX.Element | null, string | null] {
const { hideDefaultAtSign, replies } = settings.use(["hideDefaultAtSign", "replies"]);
const { message, userOverride, isRepliedMessage, withMentionPrefix } = props;
- const isWebhook = !!message.webhookId && !message.interaction;
- const channel = ChannelStore.getChannel(message.channel_id) || {};
- const target = userOverride || message.author;
- const user = isWebhook ? target : UserStore.getUser(target.id);
- const member = isWebhook ? null : GuildMemberStore.getMember(channel.guild_id, target.id);
+ const isWebhook = !!message?.webhookId && !message?.interaction;
+ const channel = message ? ChannelStore.getChannel(message.channel_id) || null : null;
+ const target = userOverride || message?.author;
+ const user = isWebhook ? target : target ? UserStore.getUser(target.id) : null;
+ const member = isWebhook ? null : target && channel ? GuildMemberStore.getMember(channel.guild_id, target.id) : null;
const author = user && member ? { ...user, ...member } : user || member || null;
const mentionSymbol = hideDefaultAtSign && (!isRepliedMessage || replies) ? "" : withMentionPrefix ? "@" : "";
- return renderUsername(author, channel.id, message.id, isRepliedMessage ? "replies" : "messages", mentionSymbol);
+ return renderUsername(author, channel?.id || null, message?.id || null, isRepliedMessage ? "replies" : "messages", mentionSymbol);
}
function getMessageNameElement(props: messageProps): JSX.Element | null {
@@ -487,8 +487,7 @@ function renderUsername(
} else if (isVoice && !reactions) {
return [null, null, null];
} else if (!author || !username) {
- const fallbackText = `${mentionSymbol}Unknown`;
- return [fallbackText, <>{fallbackText}>, fallbackText];
+ return [null, null, null];
}
const prioritizeUsername = (new Set([first, second, third, fourth, fifth].filter(Boolean).map(pos => pos.name.toLowerCase())).size > 1);
@@ -917,6 +916,14 @@ export default definePlugin({
}
]
},
+ {
+ // Replace names in DMs list.
+ find: "ImpressionNames.DM_LIST_RIGHT_CLICK_MENU_SHOWN",
+ replacement: {
+ match: /(?<=getMentionCount\(\i.id\)>0\),\i=)/,
+ replace: "$self.getMemberListProfilesReactionsVoiceNameText({...arguments[0],type:\"membersList\"})??"
+ },
+ },
{
// Track hovering on messages to animate gradients.
// Attach the group ID to their messages to allow animating gradients within a group.