fixing some bugs to adapt with the new TablistComponents data type

This commit is contained in:
programminglaboratorys 2024-04-27 19:48:20 +03:00
parent 955232f4d6
commit c7244d8b26
2 changed files with 15 additions and 16 deletions

View file

@ -1,4 +1,5 @@
import { Channel } from "discord-types/general"; import { Channel } from "discord-types/general";
import ErrorBoundary from "@components/ErrorBoundary";
//import { Logger } from "@utils/Logger"; //import { Logger } from "@utils/Logger";
//const logger = new Logger("Tablist"); useless //const logger = new Logger("Tablist"); useless
@ -44,24 +45,22 @@ export const addTablistButton = (id: string, tab: string, PanelComponent: Tablis
export const removeTablistButton = (id: string) => TablistComponents.delete(id); export const removeTablistButton = (id: string) => TablistComponents.delete(id);
export function* RenderButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string, expressionMate: ExpressionMate) { export function* RenderButtons(TablistButtonComponent: TablistButtonComponent, selectedTab: string) {
for (const tab in TablistComponents) { for (const [id, { tab }] of TablistComponents) {
yield (<TablistButtonComponent yield (<TablistButtonComponent
id={tab + "-picker-tab"} id={id + "-picker-tab"}
aria-controls={tab + "-picker-tab-panel"} aria-controls={id + "-picker-tab-panel"}
aria-selected={tab === selectedTab} aria-selected={id === selectedTab}
viewType={tab} viewType={id}
isActive={tab === selectedTab} isActive={id === selectedTab}
expressionMate={expressionMate} >{tab}</TablistButtonComponent>);
>{TablistComponents[tab].tab}
</TablistButtonComponent>);
} }
} }
export function* TabPanels(selectedTab: string, expressionMate: ExpressionMate, channel: Channel) { export function* TabPanels(selectedTab: string, expressionMate: ExpressionMate, channel: Channel) {
for (const tab in TablistComponents) { for (const [id, { Component }] of TablistComponents) {
if (tab !== selectedTab) { continue; } if (id !== selectedTab) { continue; }
let PanelComponent: TablistPanelComponent = TablistComponents[tab].Component; let PanelComponent: TablistPanelComponent = Component;
yield (<PanelComponent selectedTab={selectedTab} channel={channel} expressionMate={expressionMate} />); yield (<ErrorBoundary><PanelComponent selectedTab={selectedTab} channel={channel} expressionMate={expressionMate} /></ErrorBoundary>);
} }
} }

View file

@ -11,8 +11,8 @@ export default definePlugin({
find: ".EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL", find: ".EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL",
replacement: [ replacement: [
{ {
match: /\.jsx)\((\i),\{id:\i\.\i,.+?,"aria-selected":(\i)===.+?,viewType:(\i).+?\}\)/,//\] match: /\.jsx\)\((\i),\{id:\i\.E\i,.+?,"aria-selected":(\i)===\i\.\i\.EMOJI.+?,viewType:(\i).+?\}\)/,
replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2, $3)" replace: "$&,...Vencord.Api.Tablist.RenderButtons($1, $2)"
}, },
{ {
match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/, match: /null,(\i)===(\i)\.ExpressionPickerViewType\.EMOJI\?.{0,55}channel:(\i),.+?\):null/,