vd-plugins/nexxstuff/lib/pinToSettings/index.ts
kmmiio99o b98ce51645
feat: add nexx lib and better Header text
nexx shouldn't be mad, right?
2026-01-25 17:09:24 +01:00

30 lines
677 B
TypeScript

import { patchPanelUI } from "./panel";
import { patchTabsUI } from "./tabs";
export interface PinToSettingsTabs {
key: string;
title: () => string;
icon?: number;
predicate?: () => boolean;
trailing?: () => React.ReactNode;
page: React.ComponentType;
}
export function patchSettingsPin(tabs: PinToSettingsTabs): () => void {
const patches: (() => void)[] = [];
let disabled = false;
const realPredicate = tabs.predicate ?? (() => true);
tabs.predicate = () => (disabled ? false : realPredicate());
patchPanelUI(tabs, patches);
patchTabsUI(tabs, patches);
patches.push(() => (disabled = true));
return () => {
for (const x of patches) {
x();
}
};
}