aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/pronoundb/components
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-11-11 16:14:05 +0100
committerVendicated <vendicated@riseup.net>2022-11-11 16:14:09 +0100
commit1176896a1b7aa5615b4aae28cc885683f0dadd1a (patch)
treed314a46e6ddcab6e3f328d0a3f535319e7c8f796 /src/plugins/pronoundb/components
parentf3aba3edb0fc67118546629f7dbdda5ff6b0ebff (diff)
downloadVencord-1176896a1b7aa5615b4aae28cc885683f0dadd1a.tar.gz
Vencord-1176896a1b7aa5615b4aae28cc885683f0dadd1a.tar.bz2
Vencord-1176896a1b7aa5615b4aae28cc885683f0dadd1a.zip
fix(plugins): PronounDB, ViewIcons, WebhookTags, NoBlockedMessages, BetterGifAltText, MessageAccessories
Diffstat (limited to 'src/plugins/pronoundb/components')
-rw-r--r--src/plugins/pronoundb/components/PronounsProfileWrapper.tsx23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx
index 4d12dd5..139fb8a 100644
--- a/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx
+++ b/src/plugins/pronoundb/components/PronounsProfileWrapper.tsx
@@ -20,27 +20,28 @@ import { useAwaiter } from "../../../utils/misc";
import { Settings } from "../../../Vencord";
import { UserStore } from "../../../webpack/common";
import { fetchPronouns, formatPronouns } from "../pronoundbUtils";
-import { PronounMapping, UserProfileProps } from "../types";
+import { PronounMapping, UserProfilePronounsProps, UserProfileProps } from "../types";
-export default function PronounsProfileWrapper(props: UserProfileProps, pronounsComponent: JSX.Element) {
+export default function PronounsProfileWrapper(PronounsComponent: React.ElementType<UserProfilePronounsProps>, props: UserProfilePronounsProps, profileProps: UserProfileProps) {
+ const user = UserStore.getUser(profileProps.userId) ?? {};
// Don't bother fetching bot or system users
- if (props.user.bot || props.user.system) return null;
+ if (user.bot || user.system) return null;
// Respect showSelf options
- if (!Settings.plugins.PronounDB.showSelf && props.user.id === UserStore.getCurrentUser().id) return null;
+ if (!Settings.plugins.PronounDB.showSelf && user.id === UserStore.getCurrentUser().id)
+ return null;
const [result, , isPending] = useAwaiter(
- () => fetchPronouns(props.user.id),
+ () => fetchPronouns(user.id),
null,
e => console.error("Fetching pronouns failed: ", e)
);
- // If the promise completed, the result was not "unspecified", and there is a mapping for the code, then return a span with the pronouns
+ // If the promise completed, the result was not "unspecified", and there is a mapping for the code, then render
if (!isPending && result && result !== "unspecified" && PronounMapping[result]) {
// First child is the header, second is a div with the actual text
- const [, pronounsBodyComponent] = pronounsComponent.props.children as [JSX.Element, JSX.Element];
- pronounsBodyComponent.props.children = formatPronouns(result);
- return pronounsComponent;
+ props.currentPronouns ||= formatPronouns(result);
+ return <PronounsComponent {...props} />;
}
- // Otherwise, return null so nothing else is rendered
- else return null;
+
+ return null;
}