Skip to content

Commit

Permalink
fix member list rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Mar 29, 2024
1 parent ba29cc1 commit 2e9129b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 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.7",
"version": "1.3.8",
"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.7",
"version": "1.3.8",
"description": "Adds Platform Indicators for to for users to various places.",
"engines": {
"node": ">=18.0.0",
Expand Down
13 changes: 10 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { modules } from "./Modules";
import {
ClientStatus,
PlatformIndicatorsSettings,
Platforms,
PresenceStore,
SessionStore,
useStateFromStore,
Expand Down Expand Up @@ -135,13 +134,21 @@ function patchMemberList(PlatformIndicatorProps: {
modules.memberListFnName!,
([{ user }]: [{ user: User }], res: React.ReactElement, _) => {
if (!cfg.get("renderInMemberList")) return res;
if (!res?.props?.children && typeof res?.props?.children != "function") return;

if (Array.isArray(res?.props?.decorators?.props?.children) && user) {
const children = res?.props?.children();

if (Array.isArray(children.props?.decorators?.props?.children) && user) {
const icon = <PlatformIndicatorComponent user={user} {...PlatformIndicatorProps} />;
if (icon === null) return res; // to prevent adding an empty div
const a = <ErrorBoundary>{icon}</ErrorBoundary>;
res?.props?.decorators?.props?.children.push(a);
children.props?.decorators?.props?.children.push(a);
}

res.props.children = () => {
return children;
};

return res;
},
);
Expand Down

0 comments on commit 2e9129b

Please sign in to comment.