aboutsummaryrefslogtreecommitdiff
path: root/src/api/Badges.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/Badges.ts')
-rw-r--r--src/api/Badges.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/api/Badges.ts b/src/api/Badges.ts
index d4aabaf..9abaefe 100644
--- a/src/api/Badges.ts
+++ b/src/api/Badges.ts
@@ -29,11 +29,12 @@ export enum BadgePosition {
export interface ProfileBadge {
/** The tooltip to show on hover. Required for image badges */
- tooltip?: string;
+ description?: string;
/** Custom component for the badge (tooltip not included) */
component?: ComponentType<ProfileBadge & BadgeUserArgs>;
/** The custom image to use */
image?: string;
+ link?: string;
/** Action to perform when you click the badge */
onClick?(): void;
/** Should the user display this badge? */
@@ -69,17 +70,19 @@ export function removeBadge(badge: ProfileBadge) {
* Inject badges into the profile badges array.
* You probably don't need to use this.
*/
-export function inject(badgeArray: ProfileBadge[], args: BadgeUserArgs) {
+export function _getBadges(args: BadgeUserArgs) {
+ const badges = [] as ProfileBadge[];
for (const badge of Badges) {
if (!badge.shouldShow || badge.shouldShow(args)) {
badge.position === BadgePosition.START
- ? badgeArray.unshift({ ...badge, ...args })
- : badgeArray.push({ ...badge, ...args });
+ ? badges.unshift({ ...badge, ...args })
+ : badges.push({ ...badge, ...args });
}
}
- (Plugins.BadgeAPI as any).addDonorBadge(badgeArray, args.user.id);
+ const donorBadge = (Plugins.BadgeAPI as any).getDonorBadge(args.user.id);
+ if (donorBadge) badges.unshift(donorBadge);
- return badgeArray;
+ return badges;
}
export interface BadgeUserArgs {