Skip to content

Commit

Permalink
PronounDB: Fix crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckyz committed Sep 22, 2024
1 parent b0e2f31 commit 409f47b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/plugins/pronoundb/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { getCurrentChannel } from "@utils/discord";
import { useAwaiter } from "@utils/react";
import { findStoreLazy } from "@webpack";
import { UserProfileStore } from "@webpack/common";
import { UserProfileStore, UserStore } from "@webpack/common";

import { settings } from "./settings";
import { PronounMapping, Pronouns, PronounsCache, PronounSets, PronounsFormat, PronounSource, PronounsResponse } from "./types";
Expand Down Expand Up @@ -158,10 +158,15 @@ export function useFormattedPronouns(id: string, useGlobalProfile: boolean = fal
}

export function useProfilePronouns(id: string, useGlobalProfile: boolean = false): Pronouns {
const pronouns = useFormattedPronouns(id, useGlobalProfile);
try {
const pronouns = useFormattedPronouns(id, useGlobalProfile);

if (!settings.store.showInProfile) return EmptyPronouns;
if (!settings.store.showSelf && id === UserProfileStore.getCurrentUser()?.id) return EmptyPronouns;
if (!settings.store.showInProfile) return EmptyPronouns;
if (!settings.store.showSelf && id === UserStore.getCurrentUser()?.id) return EmptyPronouns;

return pronouns;
return pronouns;
} catch (e) {
console.error(e);
return EmptyPronouns;
}
}

0 comments on commit 409f47b

Please sign in to comment.