mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-09 06:33:03 -04:00
MoreUserTags Chat
This commit is contained in:
parent
61e75e1d89
commit
2613ec170e
17 changed files with 668 additions and 228 deletions
40
src/api/NicknameIcons.tsx
Normal file
40
src/api/NicknameIcons.tsx
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2025 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { ReactNode } from "react";
|
||||
|
||||
export interface NicknameIconProps {
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export type NicknameIconFactory = (props: NicknameIconProps) => ReactNode | Promise<ReactNode>;
|
||||
|
||||
export interface NicknameIcon {
|
||||
priority: number;
|
||||
factory: NicknameIconFactory;
|
||||
}
|
||||
|
||||
const nicknameIcons = new Map<string, NicknameIcon>();
|
||||
const logger = new Logger("NicknameIcons");
|
||||
|
||||
export function addNicknameIcon(id: string, factory: NicknameIconFactory, priority = 0) {
|
||||
return nicknameIcons.set(id, {
|
||||
priority,
|
||||
factory: ErrorBoundary.wrap(factory, { noop: true, onError: error => logger.error(`Failed to render ${id}`, error) })
|
||||
});
|
||||
}
|
||||
|
||||
export function removeNicknameIcon(id: string) {
|
||||
return nicknameIcons.delete(id);
|
||||
}
|
||||
|
||||
export function _renderIcons(props: NicknameIconProps) {
|
||||
return Array.from(nicknameIcons)
|
||||
.sort((a, b) => b[1].priority - a[1].priority)
|
||||
.map(([id, { factory: NicknameIcon }]) => <NicknameIcon key={id} {...props} />);
|
||||
}
|
|
@ -27,6 +27,7 @@ import * as $MessageDecorations from "./MessageDecorations";
|
|||
import * as $MessageEventsAPI from "./MessageEvents";
|
||||
import * as $MessagePopover from "./MessagePopover";
|
||||
import * as $MessageUpdater from "./MessageUpdater";
|
||||
import * as $NicknameIcons from "./NicknameIcons";
|
||||
import * as $Notices from "./Notices";
|
||||
import * as $Notifications from "./Notifications";
|
||||
import * as $ServerList from "./ServerList";
|
||||
|
@ -123,6 +124,11 @@ export const MessageUpdater = $MessageUpdater;
|
|||
*/
|
||||
export const UserSettings = $UserSettings;
|
||||
|
||||
/**
|
||||
* An API allowing you to add icons to the nickname, in profiles
|
||||
*/
|
||||
export const NicknameIcons = $NicknameIcons;
|
||||
|
||||
/**
|
||||
* Just used to identify if user is on Equicord as Vencord doesnt have this
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue