From 487384c97ea3cca5f6692a353637a3bfd6aeff14 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Fri, 20 Mar 2026 20:31:15 -0400 Subject: [PATCH] ProfileCollectionsAPI: Apply Some Misc Fixes --- src/api/PluginManager.ts | 2 +- src/api/ProfileCollections.tsx | 15 +++------------ src/equicordplugins/githubRepos/index.tsx | 4 ++-- .../songSpotlight.desktop/index.tsx | 2 +- src/plugins/gameActivityToggle/index.tsx | 2 -- src/plugins/gameActivityToggle/style.css | 3 --- src/plugins/reviewDB/index.tsx | 5 ++--- 7 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 src/plugins/gameActivityToggle/style.css diff --git a/src/api/PluginManager.ts b/src/api/PluginManager.ts index b848fd268..5a06dbd8b 100644 --- a/src/api/PluginManager.ts +++ b/src/api/PluginManager.ts @@ -268,7 +268,7 @@ export const startPlugin = traceFunction("startPlugin", function startPlugin(p: } if (audioProcessor) addAudioProcessor(name, audioProcessor); if (userAreaButton) addUserAreaButton(name, userAreaButton.render, userAreaButton.priority); - if (renderProfileCollection) addProfileCollection(name, renderProfileCollection, userAreaButton?.priority); + if (renderProfileCollection) addProfileCollection(name, renderProfileCollection); return true; }, p => `startPlugin ${p.name}`); diff --git a/src/api/ProfileCollections.tsx b/src/api/ProfileCollections.tsx index 898332b62..362315978 100644 --- a/src/api/ProfileCollections.tsx +++ b/src/api/ProfileCollections.tsx @@ -7,22 +7,14 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Logger } from "@utils/Logger"; import { useEffect, useState } from "@webpack/common"; -import type { JSX } from "react"; +import type { JSX, ReactNode } from "react"; const logger = new Logger("ProfileCollectionAPI"); -export type ProfileCollectionFactory = Function; - -export interface ProfileCollectionData { - /** Function that renders the collection component, receives the full profile props */ - render: ProfileCollectionFactory; - /** Higher priority collections appear first in the list. Default: 0 */ - priority?: number; -} +export type ProfileCollectionFactory = (props: any) => ReactNode | null; interface CollectionEntry { render: ProfileCollectionFactory; - priority: number; } const profileCollections = new Map(); @@ -41,7 +33,7 @@ const profileCollectionListeners = new Set<() => void>(); * )); */ export function addProfileCollection(id: string, render: ProfileCollectionFactory, priority = 0) { - profileCollections.set(id, { render, priority }); + profileCollections.set(id, { render }); profileCollectionListeners.forEach(listener => listener()); } @@ -65,7 +57,6 @@ function ProfileCollections({ props }: { props: any; }) { }, []); return Array.from(profileCollections) - .sort(([, a], [, b]) => b.priority - a.priority) .map(([id, { render: Collection }]) => ( logger.error(`Failed to render profile collection: ${id}`, e.error)}> {Collection({ ...props, user: props.user ?? props.currentUser })} diff --git a/src/equicordplugins/githubRepos/index.tsx b/src/equicordplugins/githubRepos/index.tsx index 87285bf5d..75f566a82 100644 --- a/src/equicordplugins/githubRepos/index.tsx +++ b/src/equicordplugins/githubRepos/index.tsx @@ -59,14 +59,14 @@ export default definePlugin({ } } ], - renderProfileCollection: ErrorBoundary.wrap((props: { user: User; displayProfile?: any; }) => { + renderProfileCollection: (props: { user: User; displayProfile?: any; }) => { return ( ); - }, { noop: true }), + }, renderProfileRepositoriesTab: ErrorBoundary.wrap((props: { user: User; displayProfile?: any; }) => { return ( . */ -import "./style.css"; - import { isPluginEnabled } from "@api/PluginManager"; import { definePluginSettings } from "@api/Settings"; import { UserAreaButton, UserAreaRenderProps } from "@api/UserArea"; diff --git a/src/plugins/gameActivityToggle/style.css b/src/plugins/gameActivityToggle/style.css deleted file mode 100644 index 37e6ace08..000000000 --- a/src/plugins/gameActivityToggle/style.css +++ /dev/null @@ -1,3 +0,0 @@ -[class*="panels"] [class*="avatarWrapper"] { - min-width: 0; -} diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index a7f3d2660..393237e0e 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -19,7 +19,6 @@ import "./style.css"; import { NavContextMenuPatchCallback } from "@api/ContextMenu"; -import ErrorBoundary from "@components/ErrorBoundary"; import { OpenExternalIcon } from "@components/Icons"; import { Paragraph } from "@components/Paragraph"; import { Span } from "@components/Span"; @@ -136,7 +135,7 @@ export default definePlugin({ }, 4000); }, - renderProfileCollection: ErrorBoundary.wrap(({ user, isSideBar = false }: { user: User; isSideBar?: boolean; }) => { + renderProfileCollection: ({ user, isSideBar = false }: { user: User; isSideBar?: boolean; }) => { const [reviewData] = useAwaiter(() => getReviews(user.id, { limit: 4 }), { deps: [user.id], fallbackValue: null }); // Discord are masters at using a crap ton of html elements and css classes to create a simple ui that could have @@ -193,5 +192,5 @@ export default definePlugin({ return isSideBar ?
{reviewsSection}
: reviewsSection; - }, { noop: true }) + } });