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",
|
"onBeforeMessageEdit", "onBeforeMessageSend", "onMessageClick",
|
||||||
"renderMemberListDecorator", "renderMessageAccessory", "renderMessageDecoration",
|
"renderMemberListDecorator", "renderMessageAccessory", "renderMessageDecoration",
|
||||||
// Custom
|
// Custom
|
||||||
"renderNicknameIcon", "renderProfileCollection", "renderProfileSection"
|
"renderNicknameIcon"
|
||||||
];
|
];
|
||||||
|
|
||||||
const neededApiPlugins = new Set<string>();
|
const neededApiPlugins = new Set<string>();
|
||||||
|
|
@ -430,7 +430,7 @@ export const initPluginManager = onlyOnce(function init() {
|
||||||
if (p.renderProfileSection) neededApiPlugins.add("ProfileSectionsAPI");
|
if (p.renderProfileSection) neededApiPlugins.add("ProfileSectionsAPI");
|
||||||
|
|
||||||
for (const key of pluginKeysToBind) {
|
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) => {
|
chatBarButtonWrapper: {
|
||||||
if (!Array.isArray(buttons) || buttons.length === 0) return buttons;
|
wrapper: (buttons: ReactNode) => {
|
||||||
return <ChatButtonsRow buttons={buttons} />;
|
if (!Array.isArray(buttons) || buttons.length === 0) return buttons;
|
||||||
|
return <ChatButtonsRow buttons={buttons} />;
|
||||||
|
},
|
||||||
|
priority: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
userAreaControlsClass(className: string) {
|
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) {
|
shouldShowGitHub(userId: string) {
|
||||||
return UserProfileStore.getUserProfile(userId)?.connectedAccounts?.some((c: any) => c.type === "github") ?? false;
|
return UserProfileStore.getUserProfile(userId)?.connectedAccounts?.some((c: any) => c.type === "github") ?? false;
|
||||||
},
|
},
|
||||||
renderProfileCollection: (props: { user: User; displayProfile?: any; }) => {
|
renderProfileCollection: {
|
||||||
return (
|
render: (props: { user: User; displayProfile?: any; }) => {
|
||||||
<ProfilePopoutComponent
|
return (
|
||||||
{...props}
|
<ProfilePopoutComponent
|
||||||
id={props.user.id}
|
{...props}
|
||||||
/>
|
id={props.user.id}
|
||||||
);
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
priority: 0,
|
||||||
},
|
},
|
||||||
renderProfileRepositoriesTab: ErrorBoundary.wrap((props: { user: User; displayProfile?: any; }) => {
|
renderProfileRepositoriesTab: ErrorBoundary.wrap((props: { user: User; displayProfile?: any; }) => {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,11 @@ export default definePlugin({
|
||||||
dependencies: ["ChatInputButtonAPI"],
|
dependencies: ["ChatInputButtonAPI"],
|
||||||
settings: settings,
|
settings: settings,
|
||||||
startAt: StartAt.Init,
|
startAt: StartAt.Init,
|
||||||
chatBarButtonWrapper: (buttons: ReactNode) => {
|
chatBarButtonWrapper: {
|
||||||
return <ButtonsInnerComponent buttons={buttons} />;
|
wrapper: (buttons: ReactNode) => {
|
||||||
|
return <ButtonsInnerComponent buttons={buttons} />;
|
||||||
|
},
|
||||||
|
priority: 0,
|
||||||
},
|
},
|
||||||
start() {
|
start() {
|
||||||
hidechatbuttonsopen = settings.store.open;
|
hidechatbuttonsopen = settings.store.open;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,9 @@ export default definePlugin({
|
||||||
useAuthorizationStore.persist.rehydrate();
|
useAuthorizationStore.persist.rehydrate();
|
||||||
},
|
},
|
||||||
|
|
||||||
renderProfileCollection: ProfileSongs,
|
renderProfileCollection: {
|
||||||
|
render: ProfileSongs,
|
||||||
|
priority: 0,
|
||||||
|
},
|
||||||
renderWidgetSongs: ErrorBoundary.wrap(WidgetSongs, { noop: true }),
|
renderWidgetSongs: ErrorBoundary.wrap(WidgetSongs, { noop: true }),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,10 @@ export default definePlugin({
|
||||||
tags: ["Voice", "Friends"],
|
tags: ["Voice", "Friends"],
|
||||||
authors: [EquicordDevs.Moowi],
|
authors: [EquicordDevs.Moowi],
|
||||||
dependencies: ["ProfileSectionsAPI"],
|
dependencies: ["ProfileSectionsAPI"],
|
||||||
renderProfileSection: VoiceStatsSection,
|
renderProfileSection: {
|
||||||
|
render: VoiceStatsSection,
|
||||||
|
priority: 0,
|
||||||
|
},
|
||||||
flux: {
|
flux: {
|
||||||
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
|
||||||
const myId = UserStore.getCurrentUser()?.id;
|
const myId = UserStore.getCurrentUser()?.id;
|
||||||
|
|
|
||||||
|
|
@ -76,5 +76,8 @@ export default definePlugin({
|
||||||
tags: ["Friends"],
|
tags: ["Friends"],
|
||||||
authors: [Devs.Elvyra, Devs.Antti],
|
authors: [Devs.Elvyra, Devs.Antti],
|
||||||
dependencies: ["ProfileSectionsAPI"],
|
dependencies: ["ProfileSectionsAPI"],
|
||||||
renderProfileSection: FriendsSinceSection,
|
renderProfileSection: {
|
||||||
|
render: FriendsSinceSection,
|
||||||
|
priority: 0,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,9 @@ export default definePlugin({
|
||||||
}, 4000);
|
}, 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 });
|
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
|
// 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
|
return isSideBar
|
||||||
? <div className={DMSideBarClasses.widgetPreviews}>{reviewsSection}</div>
|
? <div className={DMSideBarClasses.widgetPreviews}>{reviewsSection}</div>
|
||||||
: reviewsSection;
|
: reviewsSection;
|
||||||
}
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue