mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-21 15:48:52 -05:00
Fixes
This commit is contained in:
commit
9bdb8a88a8
7 changed files with 37 additions and 59 deletions
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { User } from "discord-types/general";
|
||||
import { ComponentType, HTMLProps } from "react";
|
||||
|
||||
import Plugins from "~plugins";
|
||||
|
@ -79,9 +78,9 @@ export function _getBadges(args: BadgeUserArgs) {
|
|||
: badges.push({ ...badge, ...args });
|
||||
}
|
||||
}
|
||||
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.user.id);
|
||||
const equicordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getEquicordDonorBadges(args.user.id);
|
||||
const suncordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getSuncordDonorBadges(args.user.id);
|
||||
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getDonorBadges(args.userId);
|
||||
const equicordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getEquicordDonorBadges(args.userId);
|
||||
const suncordDonorBadges = (Plugins.BadgeAPI as unknown as typeof import("../plugins/_api/badges").default).getSuncordDonorBadges(args.userId);
|
||||
if (donorBadges) badges.unshift(...donorBadges);
|
||||
if (equicordDonorBadges) badges.unshift(...equicordDonorBadges);
|
||||
if (suncordDonorBadges) badges.unshift(...suncordDonorBadges);
|
||||
|
@ -90,7 +89,7 @@ export function _getBadges(args: BadgeUserArgs) {
|
|||
}
|
||||
|
||||
export interface BadgeUserArgs {
|
||||
user: User;
|
||||
userId: string;
|
||||
guildId: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,12 +100,12 @@ export default definePlugin({
|
|||
<><Forms.FormTitle>
|
||||
<Forms.FormTitle>How to use?</Forms.FormTitle>
|
||||
</Forms.FormTitle>
|
||||
<Forms.FormText>
|
||||
<Forms.FormText>Go to <Link href="/settings/appearance" onClick={e => { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings</Link> tab.</Forms.FormText>
|
||||
<Forms.FormText>Scroll down to "In-app Icons" and click on "Preview App Icon".</Forms.FormText>
|
||||
<Forms.FormText>And upload your own custom icon!</Forms.FormText>
|
||||
<Forms.FormText>You can only use links when you are uploading your Custom Icon.</Forms.FormText>
|
||||
</Forms.FormText></>
|
||||
<Forms.FormText>
|
||||
<Forms.FormText>Go to <Link href="/settings/appearance" onClick={e => { e.preventDefault(); closeAllModals(); FluxDispatcher.dispatch({ type: "USER_SETTINGS_MODAL_SET_SECTION", section: "Appearance" }); }}>Appearance Settings</Link> tab.</Forms.FormText>
|
||||
<Forms.FormText>Scroll down to "In-app Icons" and click on "Preview App Icon".</Forms.FormText>
|
||||
<Forms.FormText>And upload your own custom icon!</Forms.FormText>
|
||||
<Forms.FormText>You can only use links when you are uploading your Custom Icon.</Forms.FormText>
|
||||
</Forms.FormText></>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -121,9 +121,9 @@ function getBadgesToApply() {
|
|||
description: rank.title,
|
||||
component: () => getBadgeComponent(rank),
|
||||
shouldShow: (info: BadgeUserArgs) => {
|
||||
if (!RelationshipStore.isFriend(info.user.id)) { return false; }
|
||||
if (!RelationshipStore.isFriend(info.userId)) { return false; }
|
||||
|
||||
const days = daysSince(RelationshipStore.getSince(info.user.id));
|
||||
const days = daysSince(RelationshipStore.getSince(info.userId));
|
||||
|
||||
if (self[index + 1] == null) {
|
||||
return days > rank.requirement;
|
||||
|
|
|
@ -20,7 +20,6 @@ import { addBadge, BadgePosition, ProfileBadge, removeBadge } from "@api/Badges"
|
|||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { React, Tooltip } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
type CustomBadge = string | {
|
||||
name: string;
|
||||
|
@ -67,9 +66,9 @@ const BadgeComponent = ({ name, img }: { name: string, img: string; }) => {
|
|||
);
|
||||
};
|
||||
|
||||
const GlobalBadges = ({ user }: { user: User; }) => {
|
||||
const GlobalBadges = ({ userId }: { userId: string; }) => {
|
||||
const [badges, setBadges] = React.useState<BadgeCache["badges"]>({});
|
||||
React.useEffect(() => setBadges(fetchBadges(user.id) ?? {}), [user.id]);
|
||||
React.useEffect(() => setBadges(fetchBadges(userId) ?? {}), [userId]);
|
||||
|
||||
if (!badges) return null;
|
||||
const globalBadges: JSX.Element[] = [];
|
||||
|
@ -104,7 +103,7 @@ const GlobalBadges = ({ user }: { user: User; }) => {
|
|||
const Badge: ProfileBadge = {
|
||||
component: b => <GlobalBadges {...b} />,
|
||||
position: BadgePosition.START,
|
||||
shouldShow: userInfo => !!Object.keys(fetchBadges(userInfo.user.id) ?? {}).length,
|
||||
shouldShow: userInfo => !!Object.keys(fetchBadges(userInfo.userId) ?? {}).length,
|
||||
key: "GlobalBadges"
|
||||
};
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import { isEquicordPluginDev, isPluginDev } from "@utils/misc";
|
|||
import { closeModal, Modals, openModal } from "@utils/modal";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Forms, Toasts, UserStore } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
|
||||
const EQUICORD_CONTRIBUTOR_BADGE = "https://i.imgur.com/rJDRtUB.png";
|
||||
|
@ -39,8 +40,8 @@ const ContributorBadge: ProfileBadge = {
|
|||
description: "Vencord Contributor",
|
||||
image: CONTRIBUTOR_BADGE,
|
||||
position: BadgePosition.START,
|
||||
shouldShow: ({ user }) => isPluginDev(user.id),
|
||||
onClick: (_, { user }) => openContributorModal(user)
|
||||
shouldShow: ({ userId }) => isPluginDev(userId),
|
||||
onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId))
|
||||
};
|
||||
|
||||
const EquicordContributorBadge: ProfileBadge = {
|
||||
|
@ -53,7 +54,7 @@ const EquicordContributorBadge: ProfileBadge = {
|
|||
transform: "scale(0.9)" // The image is a bit too big compared to default badges
|
||||
}
|
||||
},
|
||||
shouldShow: ({ user }) => isEquicordPluginDev(user.id),
|
||||
shouldShow: ({ userId }) => isEquicordPluginDev(userId),
|
||||
link: "https://github.com/Equicord/Equicord"
|
||||
};
|
||||
|
||||
|
@ -91,7 +92,7 @@ export default definePlugin({
|
|||
replacement: [
|
||||
{
|
||||
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
|
||||
replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));",
|
||||
replace: "$&$1.unshift(...$self.getBadges(arguments[0]));",
|
||||
},
|
||||
{
|
||||
// alt: "", aria-hidden: false, src: originalSrc
|
||||
|
@ -107,7 +108,7 @@ export default definePlugin({
|
|||
// conditionally override their onClick with badge.onClick if it exists
|
||||
{
|
||||
match: /href:(\i)\.link/,
|
||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, arguments[0]) }),$&"
|
||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -122,11 +123,10 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: ".description,delay:",
|
||||
group: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /...(\i)\}=\(0,\i\.useUserProfileAnalyticsContext\)\(\);/,
|
||||
replace: "$& const VencordProps=$self.getProps($1); arguments[0].badges.unshift(...$self.getBadges($1));"
|
||||
replace: "$&arguments[0].badges?.unshift(...$self.getBadges($1));"
|
||||
},
|
||||
{
|
||||
// alt: "", aria-hidden: false, src: originalSrc
|
||||
|
@ -136,35 +136,17 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
match: /(?<=text:(\i)\.description,.{0,50})children:/,
|
||||
replace: "children:$1.component ? $self.renderBadgeComponent({ ...VencordProps, ...$1 }) :"
|
||||
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
|
||||
},
|
||||
// conditionally override their onClick with badge.onClick if it exists
|
||||
{
|
||||
match: /href:(\i)\.link/,
|
||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, VencordProps) }),$&"
|
||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
getProps(props: Record<string, any>) {
|
||||
try {
|
||||
return { ...props, user: UserStore.getUser(props.userId) };
|
||||
} catch {
|
||||
return props;
|
||||
}
|
||||
},
|
||||
|
||||
getBadges(props: { userId: string; guildId: string; }) {
|
||||
try {
|
||||
const { guildId, userId } = props;
|
||||
return _getBadges({ guildId, user: UserStore.getUser(userId) });
|
||||
} catch (e) {
|
||||
new Logger("BadgeAPI#hasBadges").error(e);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
toolboxActions: {
|
||||
async "Refetch Badges"() {
|
||||
await loadAllBadges(true);
|
||||
|
@ -182,6 +164,17 @@ export default definePlugin({
|
|||
await loadAllBadges();
|
||||
},
|
||||
|
||||
getBadges(props: { userId: string; user?: User; guildId: string; }) {
|
||||
try {
|
||||
props.userId ??= props.user?.id!;
|
||||
|
||||
return _getBadges(props);
|
||||
} catch (e) {
|
||||
new Logger("BadgeAPI#hasBadges").error(e);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
renderBadgeComponent: ErrorBoundary.wrap((badge: ProfileBadge & BadgeUserArgs) => {
|
||||
const Component = badge.component!;
|
||||
return <Component {...badge} />;
|
||||
|
|
|
@ -129,9 +129,9 @@ const PlatformIndicator = ({ user, wantMargin = true, wantTopMargin = false, sma
|
|||
};
|
||||
|
||||
const badge: ProfileBadge = {
|
||||
component: p => <PlatformIndicator {...p} wantMargin={false} />,
|
||||
component: p => <PlatformIndicator {...p} user={UserStore.getUser(p.userId)} wantMargin={false} />,
|
||||
position: BadgePosition.START,
|
||||
shouldShow: userInfo => !!Object.keys(getStatus(userInfo.user.id) ?? {}).length,
|
||||
shouldShow: userInfo => !!Object.keys(getStatus(userInfo.userId) ?? {}).length,
|
||||
key: "indicator"
|
||||
};
|
||||
|
||||
|
|
|
@ -84,19 +84,6 @@ export default definePlugin({
|
|||
|
||||
}
|
||||
},
|
||||
{
|
||||
find: /profileType:\i,pendingBanner:/,
|
||||
replacement: [
|
||||
{
|
||||
match: /(\i)\.premiumType/,
|
||||
replace: "$self.premiumHook($1)||$&"
|
||||
},
|
||||
{
|
||||
match: /function \i\((\i)\)\{/,
|
||||
replace: "$&$1.pendingBanner=$self.useBannerHook($1);"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
find: "\"data-selenium-video-tile\":",
|
||||
predicate: () => settings.store.voiceBackground,
|
||||
|
|
Loading…
Add table
Reference in a new issue