mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-19 03:17:02 -04:00
fix PronounDB crash with new profile in dms, force start dependencies
This commit is contained in:
parent
b48c8d8a4a
commit
81edc14070
8 changed files with 80 additions and 24 deletions
|
@ -27,12 +27,18 @@ import { PronounMapping } from "../types";
|
|||
|
||||
const styles: Record<string, string> = lazyWebpack(filters.byProps("timestampInline"));
|
||||
|
||||
export default function PronounsChatComponent({ message }: { message: Message; }) {
|
||||
export default function PronounsChatComponentWrapper({ message }: { message: Message; }) {
|
||||
// Don't bother fetching bot or system users
|
||||
if (message.author.bot || message.author.system) return null;
|
||||
if (message.author.bot || message.author.system)
|
||||
return null;
|
||||
// Respect showSelf options
|
||||
if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id) return null;
|
||||
if (!Settings.plugins.PronounDB.showSelf && message.author.id === UserStore.getCurrentUser().id)
|
||||
return null;
|
||||
|
||||
return <PronounsChatComponent message={message} />;
|
||||
}
|
||||
|
||||
function PronounsChatComponent({ message }: { message: Message; }) {
|
||||
const [result, , isPending] = useAwaiter(
|
||||
() => fetchPronouns(message.author.id),
|
||||
null,
|
||||
|
@ -47,6 +53,6 @@ export default function PronounsChatComponent({ message }: { message: Message; }
|
|||
>• {formatPronouns(result)}</span>
|
||||
);
|
||||
}
|
||||
// Otherwise, return null so nothing else is rendered
|
||||
else return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,22 @@ export default function PronounsProfileWrapper(PronounsComponent: React.ElementT
|
|||
if (!Settings.plugins.PronounDB.showSelf && user.id === UserStore.getCurrentUser().id)
|
||||
return null;
|
||||
|
||||
return <ProfilePronouns
|
||||
userId={profileProps.userId}
|
||||
Component={PronounsComponent}
|
||||
leProps={props}
|
||||
/>;
|
||||
}
|
||||
|
||||
function ProfilePronouns(
|
||||
{ userId, Component, leProps }: {
|
||||
userId: string;
|
||||
Component: React.ElementType<UserProfilePronounsProps>;
|
||||
leProps: UserProfilePronounsProps;
|
||||
}
|
||||
) {
|
||||
const [result, , isPending] = useAwaiter(
|
||||
() => fetchPronouns(user.id),
|
||||
() => fetchPronouns(userId),
|
||||
null,
|
||||
e => console.error("Fetching pronouns failed: ", e)
|
||||
);
|
||||
|
@ -39,8 +53,8 @@ export default function PronounsProfileWrapper(PronounsComponent: React.ElementT
|
|||
// 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
|
||||
props.currentPronouns ||= formatPronouns(result);
|
||||
return <PronounsComponent {...props} />;
|
||||
leProps.currentPronouns ||= formatPronouns(result);
|
||||
return <Component {...leProps} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue