Skip to content

Commit

Permalink
fix user profile patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Apr 7, 2024
1 parent cc02137 commit fd0f0a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"discordID": "498989696412549120",
"github": "Puyodead1"
},
"version": "1.3.9",
"version": "1.3.10",
"updater": {
"type": "store",
"id": "me.puyodead1.PlatformIndicators"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "replugged-platformindicators",
"version": "1.3.9",
"version": "1.3.10",
"description": "Adds Platform Indicators for to for users to various places.",
"engines": {
"node": ">=18.0.0",
Expand Down
31 changes: 24 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,36 @@ function patchProfile(PlatformIndicatorProps: {
if (!cfg.get("renderInProfile")) return res;
const user = args.user as User;

const theChildren = res?.props?.children;
if (!theChildren || !user || !(theChildren instanceof Array)) return res;
const theChildren = res?.props?.children?.props?.children;

if (!theChildren) {
logger.error("[patchProfile] No children found", res);
return res;
}

if (!user) {
logger.error("[patchProfile] No user found", args);
return res;
}

if (!(theChildren instanceof Array)) {
logger.error("[patchProfile] Children is not an array", res);
return res;
}

const icon = <PlatformIndicatorComponent user={user} {...PlatformIndicatorProps} />;
if (icon === null) return res; // to prevent adding an empty div
const a = <ErrorBoundary>{icon}</ErrorBoundary>;
res.props.children = [a, ...theChildren];
res.props.children.props.children = [a, ...theChildren];

if (theChildren.length > 0) {
if (!res.props.className.includes(modules.userBadgeClasses?.containerWithContent))
res.props.className += ` ${modules.userBadgeClasses?.containerWithContent}`;
if (
!res.props.children.props.className.includes(modules.userBadgeClasses?.containerWithContent)
)
res.props.children.props.className += ` ${modules.userBadgeClasses?.containerWithContent}`;

if (!res.props.className.includes("platform-indicator-badge-container"))
res.props.className += " platform-indicator-badge-container";
if (!res.props.children.props.className.includes("platform-indicator-badge-container"))
res.props.children.props.className += " platform-indicator-badge-container";
}

return res;
Expand Down

0 comments on commit fd0f0a2

Please sign in to comment.