From 7b13b9a53ea92c337b9840c0050c6a47266efdcc Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 28 Apr 2023 19:15:07 +0200 Subject: PronounDB: Fix not working in profiles --- .../pronoundb/components/PronounsChatComponent.tsx | 51 ++++++++++------------ 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'src/plugins/pronoundb/components/PronounsChatComponent.tsx') diff --git a/src/plugins/pronoundb/components/PronounsChatComponent.tsx b/src/plugins/pronoundb/components/PronounsChatComponent.tsx index 70a2bf3..e302676 100644 --- a/src/plugins/pronoundb/components/PronounsChatComponent.tsx +++ b/src/plugins/pronoundb/components/PronounsChatComponent.tsx @@ -16,66 +16,59 @@ * along with this program. If not, see . */ -import { Settings } from "@api/settings"; import { classes } from "@utils/misc"; import { findByPropsLazy } from "@webpack"; import { UserStore } from "@webpack/common"; import { Message } from "discord-types/general"; -import { awaitAndFormatPronouns } from "../pronoundbUtils"; +import { useFormattedPronouns } from "../pronoundbUtils"; +import { settings } from "../settings"; const styles: Record = findByPropsLazy("timestampInline"); function shouldShow(message: Message): boolean { - // Respect showInMessages - if (!Settings.plugins.PronounDB.showInMessages) + if (!settings.store.showInMessages) return false; - // Don't bother fetching bot or system users if (message.author.bot || message.author.system) return false; - // Respect showSelf options - if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id) + if (!settings.store.showSelf && message.author.id === UserStore.getCurrentUser().id) return false; return true; } export function PronounsChatComponentWrapper({ message }: { message: Message; }) { - if (!shouldShow(message)) - return null; - - return ; + return shouldShow(message) + ? + : null; } export function CompactPronounsChatComponentWrapper({ message }: { message: Message; }) { - if (!shouldShow(message)) - return null; - - return ; + return shouldShow(message) + ? + : null; } function PronounsChatComponent({ message }: { message: Message; }) { - const result = awaitAndFormatPronouns(message.author.id); - if (result != null) { - return ( + const result = useFormattedPronouns(message.author.id); + + return result + ? ( • {result} - ); - } - - return null; + ) + : null; } export function CompactPronounsChatComponent({ message }: { message: Message; }) { - const result = awaitAndFormatPronouns(message.author.id); - if (result != null) { - return ( + const result = useFormattedPronouns(message.author.id); + + return result + ? ( • {result} - ); - } - - return null; + ) + : null; } -- cgit