From faeb4fb5856a03c75329162ff3384645075a0c07 Mon Sep 17 00:00:00 2001 From: Hugo C Date: Tue, 5 Sep 2023 19:45:44 +0200 Subject: previewMessage: Hide the button once a message is sent (#1692) Co-authored-by: V --- src/plugins/previewMessage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/previewMessage.tsx b/src/plugins/previewMessage.tsx index 2653318..9bea221 100644 --- a/src/plugins/previewMessage.tsx +++ b/src/plugins/previewMessage.tsx @@ -20,7 +20,7 @@ import { sendBotMessage } from "@api/Commands"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; -import { Button, ButtonLooks, ButtonWrapperClasses, DraftStore, DraftType, SelectedChannelStore, Tooltip, UserStore } from "@webpack/common"; +import { Button, ButtonLooks, ButtonWrapperClasses, DraftStore, DraftType, SelectedChannelStore, Tooltip, UserStore, useStateFromStores } from "@webpack/common"; interface Props { type: { @@ -31,10 +31,9 @@ interface Props { const getDraft = (channelId: string) => DraftStore.getDraft(channelId, DraftType.ChannelMessage); export function PreviewButton(chatBoxProps: Props) { - if (chatBoxProps.type.analyticsName !== "normal") return null; const channelId = SelectedChannelStore.getChannelId(); - const draft = getDraft(channelId); - + const draft = useStateFromStores([DraftStore], () => getDraft(channelId)); + if (chatBoxProps.type.analyticsName !== "normal") return null; if (!draft) return null; return ( -- cgit