remove some legacy code

This commit is contained in:
Vendicated 2026-02-10 01:30:30 +01:00
parent f9c404c229
commit 38c490533b
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
3 changed files with 11 additions and 132 deletions

View file

@ -20,7 +20,6 @@ import { definePluginSettings } from "@api/Settings";
import { BackupRestoreIcon, CloudIcon, MainSettingsIcon, PaintbrushIcon, PatchHelperIcon, PlaceholderIcon, PluginsIcon, UpdaterIcon, VesktopSettingsIcon } from "@components/Icons";
import { BackupAndRestoreTab, CloudTab, PatchHelperTab, PluginsTab, ThemesTab, UpdaterTab, VencordTab } from "@components/settings/tabs";
import { Devs } from "@utils/constants";
import { getIntlMessage } from "@utils/discord";
import { isTruthy } from "@utils/guards";
import definePlugin, { IconProps, OptionType } from "@utils/types";
import { waitFor } from "@webpack";
@ -135,19 +134,6 @@ export default definePlugin({
}
]
},
{
find: ".SEARCH_NO_RESULTS&&0===",
replacement: [
{
match: /(?<=section:(.{0,50})\.DIVIDER\}\))([,;])(?=.{0,200}(\i)\.push.{0,100}label:(\i)\.header)/,
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
},
{
match: /({(?=.+?function (\i).{0,160}(\i)=\i\.useMemo.{0,140}return \i\.useMemo\(\(\)=>\i\(\3).+?\(\)=>)\2/,
replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})`
}
]
},
{
find: "#{intl::USER_SETTINGS_ACTIONS_MENU_LABEL}",
replacement: {
@ -325,111 +311,6 @@ export default definePlugin({
customSections: [] as ((SectionTypes: SectionTypes) => any)[],
customEntries: [] as EntryOptions[],
makeSettingsCategories(SectionTypes: SectionTypes) {
return [
{
section: SectionTypes.HEADER,
label: "Vencord",
className: "vc-settings-header"
},
{
section: "VencordSettings",
label: "Vencord",
element: VencordTab,
className: "vc-settings"
},
{
section: "VencordPlugins",
label: "Plugins",
element: PluginsTab,
className: "vc-plugins"
},
{
section: "VencordThemes",
label: "Themes",
element: ThemesTab,
className: "vc-themes"
},
!IS_UPDATER_DISABLED && {
section: "VencordUpdater",
label: "Updater",
element: UpdaterTab,
className: "vc-updater"
},
{
section: "VencordCloud",
label: "Cloud",
element: CloudTab,
className: "vc-cloud"
},
{
section: "VencordBackupAndRestore",
label: "Backup & Restore",
element: BackupAndRestoreTab,
className: "vc-backup-restore"
},
IS_DEV && {
section: "VencordPatchHelper",
label: "Patch Helper",
element: PatchHelperTab,
className: "vc-patch-helper"
},
...this.customSections.map(func => func(SectionTypes)),
{
section: SectionTypes.DIVIDER
}
].filter(Boolean);
},
isRightSpot({ header, settings: s }: { header?: string; settings?: string[]; }) {
const firstChild = s?.[0];
// lowest two elements... sanity backup
if (firstChild === "LOGOUT" || firstChild === "SOCIAL_LINKS") return true;
const { settingsLocation } = settings.store;
if (settingsLocation === "bottom") return firstChild === "LOGOUT";
if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG";
if (!header) return;
try {
const names: Record<Exclude<SettingsLocation, "bottom" | "belowActivity">, string> = {
top: getIntlMessage("USER_SETTINGS"),
aboveNitro: getIntlMessage("BILLING_SETTINGS"),
belowNitro: getIntlMessage("APP_SETTINGS"),
aboveActivity: getIntlMessage("ACTIVITY_SETTINGS")
};
if (!names[settingsLocation] || names[settingsLocation].endsWith("_SETTINGS"))
return firstChild === "PREMIUM";
return header === names[settingsLocation];
} catch {
return firstChild === "PREMIUM";
}
},
patchedSettings: new WeakSet(),
addSettings(elements: any[], element: { header?: string; settings: string[]; }, sectionTypes: SectionTypes) {
if (this.patchedSettings.has(elements) || !this.isRightSpot(element)) return;
this.patchedSettings.add(elements);
elements.push(...this.makeSettingsCategories(sectionTypes));
},
wrapSettingsHook(originalHook: (...args: any[]) => Record<string, unknown>[]) {
return (...args: any[]) => {
const elements = originalHook(...args);
if (!this.patchedSettings.has(elements))
elements.unshift(...this.makeSettingsCategories(FallbackSectionTypes));
return elements;
};
},
get electronVersion() {
return VencordNative.native.getVersions().electron || window.legcord?.electron || null;
},

View file

@ -102,16 +102,10 @@ export default definePlugin({
"#{intl::ayozFl::raw}", // Avatar preview
].map(find => ({
find,
replacement: [
{
match: /(?<=userValue.{0,25}void 0:)((\i)\.avatarDecoration)/,
replace: "$self.useUserDecorAvatarDecoration($2)??$1"
},
{
match: /(?<=userValue:)((\i(?:\.author)?)\?\.avatarDecoration)/,
replace: "$self.useUserDecorAvatarDecoration($2)??$1"
}
]
replacement: {
match: /(?<=userValue:)((\i(?:\.author)?)\?\.avatarDecoration)/,
replace: "$self.useUserDecorAvatarDecoration($2)??$1"
}
})),
// Patch avatar decoration preview to display Decor avatar decorations as if they are purchased
{

View file

@ -599,10 +599,14 @@ function patchFactory(moduleId: PropertyKey, originalFactory: AnyModuleFactory):
markedAsPatched = true;
}
} catch (err) {
logger.error(`Patch by ${patch.plugin} errored (Module id is ${String(moduleId)}): ${replacement.match}\n`, err);
// FIXME: Maybe fix this properly
const shouldSuppressError = patch.plugin === "ContextMenuAPI" && err instanceof SyntaxError && err.message.includes("arguments");
if (!shouldSuppressError) {
logger.error(`Patch by ${patch.plugin} errored (Module id is ${String(moduleId)}): ${replacement.match}\n`, err);
if (IS_DEV) {
diffErroredPatch(code, lastCode, lastCode.match(replacement.match)!);
if (IS_DEV) {
diffErroredPatch(code, lastCode, lastCode.match(replacement.match)!);
}
}
if (markedAsPatched) {