mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-09 06:33:03 -04:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
f7856649c7
16 changed files with 101 additions and 59 deletions
|
@ -43,20 +43,21 @@ interface DecoratorProps {
|
|||
export type MemberListDecoratorFactory = (props: DecoratorProps) => JSX.Element | null;
|
||||
type OnlyIn = "guilds" | "dms";
|
||||
|
||||
export const decorators = new Map<string, { render: MemberListDecoratorFactory, onlyIn?: OnlyIn; }>();
|
||||
export const decoratorsFactories = new Map<string, { render: MemberListDecoratorFactory, onlyIn?: OnlyIn; }>();
|
||||
|
||||
export function addMemberListDecorator(identifier: string, render: MemberListDecoratorFactory, onlyIn?: OnlyIn) {
|
||||
decorators.set(identifier, { render, onlyIn });
|
||||
decoratorsFactories.set(identifier, { render, onlyIn });
|
||||
}
|
||||
|
||||
export function removeMemberListDecorator(identifier: string) {
|
||||
decorators.delete(identifier);
|
||||
decoratorsFactories.delete(identifier);
|
||||
}
|
||||
|
||||
export function __getDecorators(props: DecoratorProps): (JSX.Element | null)[] {
|
||||
export function __getDecorators(props: DecoratorProps): JSX.Element {
|
||||
const isInGuild = !!(props.guildId);
|
||||
return Array.from(
|
||||
decorators.entries(),
|
||||
|
||||
const decorators = Array.from(
|
||||
decoratorsFactories.entries(),
|
||||
([key, { render: Decorator, onlyIn }]) => {
|
||||
if ((onlyIn === "guilds" && !isInGuild) || (onlyIn === "dms" && isInGuild))
|
||||
return null;
|
||||
|
@ -68,4 +69,10 @@ export function __getDecorators(props: DecoratorProps): (JSX.Element | null)[] {
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="vc-member-list-decorators-wrapper">
|
||||
{decorators}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -48,23 +48,29 @@ export interface MessageDecorationProps {
|
|||
}
|
||||
export type MessageDecorationFactory = (props: MessageDecorationProps) => JSX.Element | null;
|
||||
|
||||
export const decorations = new Map<string, MessageDecorationFactory>();
|
||||
export const decorationsFactories = new Map<string, MessageDecorationFactory>();
|
||||
|
||||
export function addMessageDecoration(identifier: string, decoration: MessageDecorationFactory) {
|
||||
decorations.set(identifier, decoration);
|
||||
decorationsFactories.set(identifier, decoration);
|
||||
}
|
||||
|
||||
export function removeMessageDecoration(identifier: string) {
|
||||
decorations.delete(identifier);
|
||||
decorationsFactories.delete(identifier);
|
||||
}
|
||||
|
||||
export function __addDecorationsToMessage(props: MessageDecorationProps): (JSX.Element | null)[] {
|
||||
return Array.from(
|
||||
decorations.entries(),
|
||||
export function __addDecorationsToMessage(props: MessageDecorationProps): JSX.Element {
|
||||
const decorations = Array.from(
|
||||
decorationsFactories.entries(),
|
||||
([key, Decoration]) => (
|
||||
<ErrorBoundary noop message={`Failed to render ${key} Message Decoration`} key={key}>
|
||||
<Decoration {...props} />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="vc-message-decorations-wrapper">
|
||||
{decorations}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue