diff options
author | alexia <me@alexia.lol> | 2023-07-26 01:34:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 01:34:51 +0200 |
commit | f2c6fcaa3bc8601e30f79ba34ad8388c3a0a1e4a (patch) | |
tree | 3ed0073d782775c8cdf4b250fd4e880e5a87a31c /src | |
parent | abf62f28db683cb3410c599d4d97101620b8e89b (diff) | |
download | Vencord-f2c6fcaa3bc8601e30f79ba34ad8388c3a0a1e4a.tar.gz Vencord-f2c6fcaa3bc8601e30f79ba34ad8388c3a0a1e4a.tar.bz2 Vencord-f2c6fcaa3bc8601e30f79ba34ad8388c3a0a1e4a.zip |
fix(PronounDB): don't use guild pronouns in global profile modal (#1462)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/pronoundb/index.ts | 2 | ||||
-rw-r--r-- | src/plugins/pronoundb/pronoundbUtils.ts | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/pronoundb/index.ts b/src/plugins/pronoundb/index.ts index c996551..8605869 100644 --- a/src/plugins/pronoundb/index.ts +++ b/src/plugins/pronoundb/index.ts @@ -69,7 +69,7 @@ export default definePlugin({ replacement: [ { match: /getGlobalName\(\i\);(?<=displayProfile.{0,200})/, - replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;" + replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id,true);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;" }, PRONOUN_TOOLTIP_PATCH ] diff --git a/src/plugins/pronoundb/pronoundbUtils.ts b/src/plugins/pronoundb/pronoundbUtils.ts index 07e79a7..8bde10e 100644 --- a/src/plugins/pronoundb/pronoundbUtils.ts +++ b/src/plugins/pronoundb/pronoundbUtils.ts @@ -58,16 +58,20 @@ const bulkFetch = debounce(async () => { } }); -function getDiscordPronouns(id: string) { +function getDiscordPronouns(id: string, useGlobalProfile: boolean = false) { + const globalPronouns = UserProfileStore.getUserProfile(id)?.pronouns; + + if (useGlobalProfile) return globalPronouns; + return ( UserProfileStore.getGuildMemberProfile(id, getCurrentChannel()?.guild_id)?.pronouns - || UserProfileStore.getUserProfile(id)?.pronouns + || globalPronouns ); } -export function useFormattedPronouns(id: string): PronounsWithSource { +export function useFormattedPronouns(id: string, useGlobalProfile: boolean = false): PronounsWithSource { // Discord is so stupid you can put tons of newlines in pronouns - const discordPronouns = getDiscordPronouns(id)?.trim().replace(NewLineRe, " "); + const discordPronouns = getDiscordPronouns(id, useGlobalProfile)?.trim().replace(NewLineRe, " "); const [result] = useAwaiter(() => fetchPronouns(id), { fallbackValue: getCachedPronouns(id), @@ -83,8 +87,8 @@ export function useFormattedPronouns(id: string): PronounsWithSource { return [discordPronouns, "Discord"]; } -export function useProfilePronouns(id: string): PronounsWithSource { - const pronouns = useFormattedPronouns(id); +export function useProfilePronouns(id: string, useGlobalProfile: boolean = false): PronounsWithSource { + const pronouns = useFormattedPronouns(id, useGlobalProfile); if (!settings.store.showInProfile) return EmptyPronouns; if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return EmptyPronouns; |