1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 09:56:24 +00:00

following linter rules, and renaming functions/components to match the new name of the api

This commit is contained in:
programminglaboratorys 2024-05-23 07:55:55 +03:00
parent 01f5de3793
commit 743c279adc
3 changed files with 34 additions and 33 deletions

View file

@ -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<string, TablistItem>();
const ExpressionPickerComponents = new Map<string, ExpressionPickerTabItem>();
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 (<ErrorBoundary><TablistButtonComponent
export function* RenderTabButtons(ExpressionPickerButtonComponent: ExpressionPickerButtonComponent, selectedTab: string) {
for (const [id, { tab }] of ExpressionPickerComponents) {
yield (<ErrorBoundary><ExpressionPickerButtonComponent
id={id + "-picker-tab"}
aria-controls={id + "-picker-tab-panel"}
aria-selected={id === selectedTab}
viewType={id}
isActive={id === selectedTab}
>{tab}</TablistButtonComponent></ErrorBoundary>);
>{tab}</ExpressionPickerButtonComponent></ErrorBoundary>);
}
}
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 (<ErrorBoundary><PanelComponent selectedTab={selectedTab} channel={channel} expressionMate={expressionMate} /></ErrorBoundary>);
const PanelComponent: ExpressionPickerPanelComponent = Component;
yield (<ErrorBoundary><PanelComponent selectedTab={selectedTab} channel={channel} /></ErrorBoundary>);
}
}

View file

@ -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

View file

@ -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)"
}
]
}