plugins: migrate to priority-based wrapper apis (#1070)
This commit is contained in:
parent
4eb7c7fcc7
commit
4127eb22d6
9 changed files with 44 additions and 20 deletions
|
|
@ -383,7 +383,7 @@ export const initPluginManager = onlyOnce(function init() {
|
|||
"onBeforeMessageEdit", "onBeforeMessageSend", "onMessageClick",
|
||||
"renderMemberListDecorator", "renderMessageAccessory", "renderMessageDecoration",
|
||||
// Custom
|
||||
"renderNicknameIcon", "renderProfileCollection", "renderProfileSection"
|
||||
"renderNicknameIcon"
|
||||
];
|
||||
|
||||
const neededApiPlugins = new Set<string>();
|
||||
|
|
@ -430,7 +430,7 @@ export const initPluginManager = onlyOnce(function init() {
|
|||
if (p.renderProfileSection) neededApiPlugins.add("ProfileSectionsAPI");
|
||||
|
||||
for (const key of pluginKeysToBind) {
|
||||
p[key] &&= p[key].bind(p) as any;
|
||||
p[key] &&= (p[key] as Function).bind(p) as any;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,9 +131,12 @@ export default definePlugin({
|
|||
}
|
||||
},
|
||||
],
|
||||
chatBarButtonWrapper: (buttons: ReactNode) => {
|
||||
if (!Array.isArray(buttons) || buttons.length === 0) return buttons;
|
||||
return <ChatButtonsRow buttons={buttons} />;
|
||||
chatBarButtonWrapper: {
|
||||
wrapper: (buttons: ReactNode) => {
|
||||
if (!Array.isArray(buttons) || buttons.length === 0) return buttons;
|
||||
return <ChatButtonsRow buttons={buttons} />;
|
||||
},
|
||||
priority: 0,
|
||||
},
|
||||
|
||||
userAreaControlsClass(className: string) {
|
||||
|
|
|
|||
|
|
@ -229,5 +229,8 @@ export default definePlugin({
|
|||
});
|
||||
},
|
||||
|
||||
chatBarButtonWrapper: wrapChatBarChildren,
|
||||
chatBarButtonWrapper: {
|
||||
wrapper: wrapChatBarChildren,
|
||||
priority: 0,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,13 +64,16 @@ export default definePlugin({
|
|||
shouldShowGitHub(userId: string) {
|
||||
return UserProfileStore.getUserProfile(userId)?.connectedAccounts?.some((c: any) => c.type === "github") ?? false;
|
||||
},
|
||||
renderProfileCollection: (props: { user: User; displayProfile?: any; }) => {
|
||||
return (
|
||||
<ProfilePopoutComponent
|
||||
{...props}
|
||||
id={props.user.id}
|
||||
/>
|
||||
);
|
||||
renderProfileCollection: {
|
||||
render: (props: { user: User; displayProfile?: any; }) => {
|
||||
return (
|
||||
<ProfilePopoutComponent
|
||||
{...props}
|
||||
id={props.user.id}
|
||||
/>
|
||||
);
|
||||
},
|
||||
priority: 0,
|
||||
},
|
||||
renderProfileRepositoriesTab: ErrorBoundary.wrap((props: { user: User; displayProfile?: any; }) => {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -88,8 +88,11 @@ export default definePlugin({
|
|||
dependencies: ["ChatInputButtonAPI"],
|
||||
settings: settings,
|
||||
startAt: StartAt.Init,
|
||||
chatBarButtonWrapper: (buttons: ReactNode) => {
|
||||
return <ButtonsInnerComponent buttons={buttons} />;
|
||||
chatBarButtonWrapper: {
|
||||
wrapper: (buttons: ReactNode) => {
|
||||
return <ButtonsInnerComponent buttons={buttons} />;
|
||||
},
|
||||
priority: 0,
|
||||
},
|
||||
start() {
|
||||
hidechatbuttonsopen = settings.store.open;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ export default definePlugin({
|
|||
useAuthorizationStore.persist.rehydrate();
|
||||
},
|
||||
|
||||
renderProfileCollection: ProfileSongs,
|
||||
renderProfileCollection: {
|
||||
render: ProfileSongs,
|
||||
priority: 0,
|
||||
},
|
||||
renderWidgetSongs: ErrorBoundary.wrap(WidgetSongs, { noop: true }),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -140,7 +140,10 @@ export default definePlugin({
|
|||
tags: ["Voice", "Friends"],
|
||||
authors: [EquicordDevs.Moowi],
|
||||
dependencies: ["ProfileSectionsAPI"],
|
||||
renderProfileSection: VoiceStatsSection,
|
||||
renderProfileSection: {
|
||||
render: VoiceStatsSection,
|
||||
priority: 0,
|
||||
},
|
||||
flux: {
|
||||
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
||||
const myId = UserStore.getCurrentUser()?.id;
|
||||
|
|
|
|||
|
|
@ -76,5 +76,8 @@ export default definePlugin({
|
|||
tags: ["Friends"],
|
||||
authors: [Devs.Elvyra, Devs.Antti],
|
||||
dependencies: ["ProfileSectionsAPI"],
|
||||
renderProfileSection: FriendsSinceSection,
|
||||
renderProfileSection: {
|
||||
render: FriendsSinceSection,
|
||||
priority: 0,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -137,7 +137,9 @@ export default definePlugin({
|
|||
}, 4000);
|
||||
},
|
||||
|
||||
renderProfileCollection: ({ user, isSideBar = false }: { user: User; isSideBar?: boolean; }) => {
|
||||
renderProfileCollection: {
|
||||
priority: 0,
|
||||
render: ({ 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
|
||||
|
|
@ -194,5 +196,6 @@ export default definePlugin({
|
|||
return isSideBar
|
||||
? <div className={DMSideBarClasses.widgetPreviews}>{reviewsSection}</div>
|
||||
: reviewsSection;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue