FullUserInChatbox: Fix empty mention when user is unknown

Fixes #3190
This commit is contained in:
Nuckyz 2025-01-31 16:24:07 -03:00
parent 7b9f0a36ba
commit 4f5ebec4bb
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -8,6 +8,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findComponentByCodeLazy } from "@webpack";
import { UserStore, useStateFromStores } from "@webpack/common";
import { ReactNode } from "react";
const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)");
@ -34,14 +35,19 @@ export default definePlugin({
}
],
UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => (
<UserMentionComponent
UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => {
const user = useStateFromStores([UserStore], () => UserStore.getUser(props.id));
if (user == null) {
return props.originalComponent();
}
return <UserMentionComponent
// This seems to be constant
className="mention"
userId={props.id}
channelId={props.channelId}
/>
), {
/>;
}, {
fallback: ({ wrappedProps: { originalComponent } }) => originalComponent()
})
});