From 4f5ebec4bb3ef9abf64668b8927405041642e37e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 31 Jan 2025 16:24:07 -0300 Subject: [PATCH] FullUserInChatbox: Fix empty mention when user is unknown Fixes #3190 --- src/plugins/fullUserInChatbox/index.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx index 5a0c41c0..ceeb5692 100644 --- a/src/plugins/fullUserInChatbox/index.tsx +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -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) => ( - { + const user = useStateFromStores([UserStore], () => UserStore.getUser(props.id)); + if (user == null) { + return props.originalComponent(); + } + + return - ), { + />; + }, { fallback: ({ wrappedProps: { originalComponent } }) => originalComponent() }) });