diff --git a/src/api/ExpressionPickerTabs.tsx b/src/api/ExpressionPickerTabs.tsx index e7ba82533..8b220f0b5 100644 --- a/src/api/ExpressionPickerTabs.tsx +++ b/src/api/ExpressionPickerTabs.tsx @@ -1,17 +1,13 @@ -import { Channel } from "discord-types/general"; +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + import ErrorBoundary from "@components/ErrorBoundary"; -//import { Logger } from "@utils/Logger"; +import { Channel } from "discord-types/general"; -//const logger = new Logger("Tablist"); useless - -export interface ExpressionMate { - CHAT_INPUT_BUTTON_CLASSNAME: string; - expressionPickerViewType: object; - expressionPickerWidths: { MIN: "min", MAX: "max"; }; - MIN_EXPRESSION_PICKER_WIDTH: number; // what's really matter here -} - -export interface TablistButtonProps { +export interface ExpressionPickerButtonProps { id?: string; "aria-controls": string; "aria-selected": boolean; @@ -22,45 +18,44 @@ export interface TablistButtonProps { [key: string]: any; } -export interface TablistPanelProps { +export interface ExpressionPickerPanelProps { selectedTab: string; channel: Channel; - expressionMate: ExpressionMate; } -export type TablistButtonComponent = (props: TablistButtonProps) => JSX.Element | null; -export type TablistPanelComponent = (props: TablistPanelProps) => JSX.Element | null; +export type ExpressionPickerButtonComponent = (props: ExpressionPickerButtonProps) => JSX.Element | null; +export type ExpressionPickerPanelComponent = (props: ExpressionPickerPanelProps) => JSX.Element | null; -export interface TablistItem { +export interface ExpressionPickerTabItem { tab: string, - Component: TablistPanelComponent; + Component: ExpressionPickerPanelComponent; autoFocus?: boolean; } -const TablistComponents = new Map(); +const ExpressionPickerComponents = new Map(); -export const addTablistButton = (id: string, tab: string, PanelComponent: TablistPanelComponent, autoFocus?: boolean) => TablistComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus }); -export const removeTablistButton = (id: string) => TablistComponents.delete(id); +export const addExpressionPickerTabButton = (id: string, tab: string, PanelComponent: ExpressionPickerPanelComponent, autoFocus?: boolean) => ExpressionPickerComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus }); +export const removeExpressionPickerTabButton = (id: string) => ExpressionPickerComponents.delete(id); -export function* RenderTabButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string) { - for (const [id, { tab }] of TablistComponents) { - yield ({tab}); + >{tab}); } } -export function* TabPanels(selectedTab: string, expressionMate: ExpressionMate, channel: Channel) { - for (const [id, { Component }] of TablistComponents) { +export function* TabPanels(selectedTab: string, channel: Channel) { + for (const [id, { Component }] of ExpressionPickerComponents) { if (id !== selectedTab) { continue; } - let PanelComponent: TablistPanelComponent = Component; - yield (); + const PanelComponent: ExpressionPickerPanelComponent = Component; + yield (); } } diff --git a/src/api/index.ts b/src/api/index.ts index fa081819f..de6e7865b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -21,6 +21,7 @@ import * as $ChatButtons from "./ChatButtons"; import * as $Commands from "./Commands"; import * as $ContextMenu from "./ContextMenu"; import * as $DataStore from "./DataStore"; +import * as $ExpressionPickerTabs from "./ExpressionPickerTabs"; import * as $MemberListDecorators from "./MemberListDecorators"; import * as $MessageAccessories from "./MessageAccessories"; import * as $MessageDecorations from "./MessageDecorations"; @@ -31,7 +32,6 @@ import * as $Notifications from "./Notifications"; import * as $ServerList from "./ServerList"; import * as $Settings from "./Settings"; import * as $Styles from "./Styles"; -import * as $ExpressionPickerTabs from "./ExpressionPickerTabs"; /** * An API allowing you to listen to Message Clicks or run your own logic diff --git a/src/plugins/_api/expressionPickerTabs.ts b/src/plugins/_api/expressionPickerTabs.ts index 3af0e4304..e75836a47 100644 --- a/src/plugins/_api/expressionPickerTabs.ts +++ b/src/plugins/_api/expressionPickerTabs.ts @@ -1,5 +1,11 @@ -import definePlugin from "@utils/types"; +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; export default definePlugin({ @@ -15,8 +21,8 @@ export default definePlugin({ replace: "$&,...Vencord.Api.ExpressionPickerTabs.RenderTabButtons($1, $2)" }, { - match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, - replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2, $3)" + match: /null,(\i)===\i\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, + replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $3)" } ] }