diff options
author | V <vendicated@riseup.net> | 2023-06-30 17:08:43 +0200 |
---|---|---|
committer | V <vendicated@riseup.net> | 2023-06-30 17:08:43 +0200 |
commit | 07a0ebb1d2ee15bcbf2c6ebb6a81546b968ae0c4 (patch) | |
tree | 774a994a0aea497d6a332a226f8675e44c4a2867 | |
parent | f09b44b0d5acbcb67570727ebdd10102a2c707f8 (diff) | |
download | Vencord-07a0ebb1d2ee15bcbf2c6ebb6a81546b968ae0c4.tar.gz Vencord-07a0ebb1d2ee15bcbf2c6ebb6a81546b968ae0c4.tar.bz2 Vencord-07a0ebb1d2ee15bcbf2c6ebb6a81546b968ae0c4.zip |
PronounDB: Fix crash when having pronouns in profile disabled
-rw-r--r-- | src/plugins/pronoundb/pronoundbUtils.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index d47d7d4..07e79a7 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -29,6 +29,9 @@ import { PronounCode, PronounMapping, PronounsResponse } from "./types"; const UserProfileStore = findStoreLazy("UserProfileStore"); +type PronounsWithSource = [string | null, string]; +const EmptyPronouns: PronounsWithSource = [null, ""]; + export const enum PronounsFormat { Lowercase = "LOWERCASE", Capitalized = "CAPITALIZED" @@ -62,7 +65,7 @@ function getDiscordPronouns(id: string) { ); } -export function useFormattedPronouns(id: string): [string | null, string] { +export function useFormattedPronouns(id: string): PronounsWithSource { // Discord is so stupid you can put tons of newlines in pronouns const discordPronouns = getDiscordPronouns(id)?.trim().replace(NewLineRe, " "); @@ -80,11 +83,11 @@ export function useFormattedPronouns(id: string): [string | null, string] { return [discordPronouns, "Discord"]; } -export function useProfilePronouns(id: string) { +export function useProfilePronouns(id: string): PronounsWithSource { const pronouns = useFormattedPronouns(id); - if (!settings.store.showInProfile) return null; - if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return null; + if (!settings.store.showInProfile) return EmptyPronouns; + if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return EmptyPronouns; return pronouns; } |