Remove Old Section Pushes

This commit is contained in:
thororen1234 2026-02-10 18:14:25 -05:00
parent af2eaab28b
commit b8dbb345c4
No known key found for this signature in database
8 changed files with 96 additions and 166 deletions

View file

@ -6,8 +6,9 @@
import "./styles.css";
import SettingsPlugin, { settingsSectionMap } from "@plugins/_core/settings";
import SettingsPlugin from "@plugins/_core/settings";
import { Devs } from "@utils/constants";
import { removeFromArray } from "@utils/misc";
import definePlugin, { StartAt } from "@utils/types";
import { SettingsRouter } from "@webpack/common";
@ -49,32 +50,17 @@ export default definePlugin({
},
},
start() {
const { customEntries, customSections } = SettingsPlugin;
customEntries.push({
SettingsPlugin.customEntries.push({
key: "equicord_components",
title: "Components",
Component: ComponentsTab,
Icon: ComponentsIcon
});
customSections.push(() => ({
section: "EquicordDiscordComponents",
label: "Components",
element: ComponentsTab,
className: "vc-discord-components",
id: "EquicordDiscordComponents"
}));
settingsSectionMap.push(["EquicordDiscordComponents", "equicord_components"]);
SettingsPlugin.settingsSectionMap.push(["EquicordDiscordComponents", "equicord_components"]);
},
stop() {
const { customEntries, customSections } = SettingsPlugin;
const entryIdx = customEntries.findIndex(e => e.key === "equicord_components");
if (entryIdx !== -1) customEntries.splice(entryIdx, 1);
const sectionIdx = customSections.findIndex(s => s({} as any).id === "EquicordDiscordComponents");
if (sectionIdx !== -1) customSections.splice(sectionIdx, 1);
const map = settingsSectionMap.findIndex(entry => entry[1] === "equicord_components");
if (map !== -1) settingsSectionMap.splice(map, 1);
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_components");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_components");
},
});

View file

@ -8,8 +8,9 @@ import "./styles.css";
import { addMessagePreSendListener, removeMessagePreSendListener } from "@api/MessageEvents";
import { EyeIcon } from "@components/Icons";
import SettingsPlugin, { settingsSectionMap } from "@plugins/_core/settings";
import SettingsPlugin from "@plugins/_core/settings";
import { EquicordDevs } from "@utils/constants";
import { removeFromArray } from "@utils/misc";
import definePlugin from "@utils/types";
import { Data } from "./components/data";
@ -24,23 +25,13 @@ export default definePlugin({
patches: [],
async start() {
const { customEntries, customSections } = SettingsPlugin;
customEntries.push({
SettingsPlugin.customEntries.push({
key: "equicord_i_remember_you",
title: "I Remember You",
Component: () => <DataUI usersCollection={data.usersCollection} />,
Icon: EyeIcon
});
customSections.push(() => ({
section: "EquicordIRememberYou",
label: "IRememberYou",
element: () => <DataUI plugin={this} usersCollection={data.usersCollection} />,
id: "EquicordIRememberYou"
}));
settingsSectionMap.push(["EquicordIRememberYou", "equicord_i_remember_you"]);
SettingsPlugin.settingsSectionMap.push(["EquicordIRememberYou", "equicord_i_remember_you"]);
const data = (this.dataManager = await new Data().withStart());
@ -54,15 +45,10 @@ export default definePlugin({
},
stop() {
const dataManager = this.dataManager as Data;
const { customEntries, customSections } = SettingsPlugin;
const entry = customEntries.findIndex(entry => entry.key === "equicord_i_remember_you");
if (entry !== -1) customEntries.splice(entry, 1);
const section = customSections.findIndex(section => section({} as any).id === "EquicordIRememberYou");
if (section !== -1) customSections.splice(section, 1);
const map = settingsSectionMap.findIndex(entry => entry[1] === "equicord_i_remember_you");
if (map !== -1) settingsSectionMap.splice(map, 1);
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_i_remember_you");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_i_remember_you");
const dataManager = this.dataManager as Data;
removeMessagePreSendListener(dataManager._onMessagePreSend_preSend);
clearInterval(dataManager._storageAutoSaveProtocol_interval);
},

View file

@ -7,8 +7,9 @@
import "./styles.css";
import { MagnifyingGlassIcon } from "@components/Icons";
import SettingsPlugin, { settingsSectionMap } from "@plugins/_core/settings";
import SettingsPlugin from "@plugins/_core/settings";
import { EquicordDevs } from "@utils/constants";
import { removeFromArray } from "@utils/misc";
import definePlugin, { StartAt } from "@utils/types";
import { SettingsRouter } from "@webpack/common";
@ -28,32 +29,17 @@ export default definePlugin({
},
settingsAboutComponent: SettingsAbout,
start() {
const { customEntries, customSections } = SettingsPlugin;
customEntries.push({
SettingsPlugin.customEntries.push({
key: "equicord_icon_viewer",
title: "Icon Finder",
Component: IconsTab,
Icon: MagnifyingGlassIcon
});
customSections.push(() => ({
section: "EquicordDiscordIcons",
label: "Icon Finder",
element: IconsTab,
className: "vc-discord-icons",
id: "EquicordIconViewer"
}));
settingsSectionMap.push(["EquicordDiscordIcons", "equicord_icon_viewer"]);
SettingsPlugin.settingsSectionMap.push(["EquicordDiscordIcons", "equicord_icon_viewer"]);
},
stop() {
const { customEntries, customSections } = SettingsPlugin;
const entryIdx = customEntries.findIndex(e => e.key === "equicord_icon_viewer");
if (entryIdx !== -1) customEntries.splice(entryIdx, 1);
const sectionIdx = customSections.findIndex(s => s({} as any).id === "EquicordIconViewer");
if (sectionIdx !== -1) customSections.splice(sectionIdx, 1);
const map = settingsSectionMap.findIndex(entry => entry[1] === "equicord_icon_viewer");
if (map !== -1) settingsSectionMap.splice(map, 1);
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_icon_viewer");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_icon_viewer");
},
});

View file

@ -7,9 +7,10 @@
import { plugins } from "@api/PluginManager";
import { definePluginSettings } from "@api/Settings";
import { Paragraph } from "@components/Paragraph";
import SettingsPlugin, { settingsSectionMap } from "@plugins/_core/settings";
import SettingsPlugin from "@plugins/_core/settings";
import { EquicordDevs } from "@utils/constants";
import { getIntlMessage } from "@utils/discord";
import { removeFromArray } from "@utils/misc";
import definePlugin, { OptionType } from "@utils/types";
import { Button } from "@webpack/common";
@ -59,37 +60,19 @@ export default definePlugin({
qrModalOpen: false,
start() {
const { customEntries, customSections } = SettingsPlugin;
customEntries.push({
SettingsPlugin.customEntries.push({
key: "equicord_login_with_qr",
title: getIntlMessage("USER_SETTINGS_SCAN_QR_CODE"),
Component: openQrModal,
Icon: QrCodeIcon
});
customSections.push(() => ({
section: "EquicordLoginWithQR",
label: getIntlMessage("USER_SETTINGS_SCAN_QR_CODE"),
searchableTitles: [getIntlMessage("USER_SETTINGS_SCAN_QR_CODE")],
element: openQrModal,
id: "EquicordLoginWithQR",
}));
settingsSectionMap.push(["EquicordLoginWithQR", "equicord_login_with_qr"]);
SettingsPlugin.settingsSectionMap.push(["EquicordLoginWithQR", "equicord_login_with_qr"]);
preload();
},
stop() {
const { customEntries, customSections } = SettingsPlugin;
const entry = customEntries.findIndex(entry => entry.key === "equicord_login_with_qr");
if (entry !== -1) customEntries.splice(entry, 1);
const section = customSections.findIndex(section => section({} as any).id === "EquicordLoginWithQR");
if (section !== -1) customSections.splice(section, 1);
const map = settingsSectionMap.findIndex(entry => entry[1] === "equicord_login_with_qr");
if (map !== -1) settingsSectionMap.splice(map, 1);
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_login_with_qr");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_login_with_qr");
unload();
},
});

View file

@ -5,8 +5,9 @@
*/
import { ColorPaletteIcon } from "@components/Icons";
import SettingsPlugin, { settingsSectionMap } from "@plugins/_core/settings";
import SettingsPlugin from "@plugins/_core/settings";
import { EquicordDevs } from "@utils/constants";
import { removeFromArray } from "@utils/misc";
import definePlugin from "@utils/types";
import { SettingsRouter } from "@webpack/common";
@ -24,33 +25,18 @@ export default definePlugin({
},
start() {
const { customEntries, customSections } = SettingsPlugin;
customEntries.push({
SettingsPlugin.customEntries.push({
key: "theme_library",
title: "Theme Library",
Component: require("./components/ThemeTab").default,
Icon: ColorPaletteIcon
});
customSections.push(() => ({
section: "EquicordThemeLibrary",
label: "Theme Library",
searchableTitles: ["Theme Library"],
element: require("./components/ThemeTab").default,
id: "EquicordThemeLibrary",
}));
settingsSectionMap.push(["EquicordThemeLibrary", "equicord_theme_library"]);
SettingsPlugin.settingsSectionMap.push(["EquicordThemeLibrary", "equicord_theme_library"]);
},
stop() {
const { customEntries, customSections } = SettingsPlugin;
const entry = customEntries.findIndex(entry => entry.key === "equicord_theme_library");
if (entry !== -1) customEntries.splice(entry, 1);
const section = customSections.findIndex(section => section({} as any).id === "EquicordThemeLibrary");
if (section !== -1) customSections.splice(section, 1);
const map = settingsSectionMap.findIndex(entry => entry[1] === "equicord_theme_library");
if (map !== -1) settingsSectionMap.splice(map, 1);
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_theme_library");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "equicord_theme_library");
},
});

View file

@ -19,6 +19,7 @@
import { ClockIcon } from "@components/Icons";
import SettingsPlugin from "@plugins/_core/settings";
import { Devs } from "@utils/constants";
import { removeFromArray } from "@utils/misc";
import definePlugin from "@utils/types";
import StartupTimingPage from "./StartupTimingPage";
@ -37,10 +38,6 @@ export default definePlugin({
SettingsPlugin.settingsSectionMap.push(["VencordStartupTimings", "vencord_startup_timings"]);
},
stop() {
function removeFromArray<T>(arr: T[], predicate: (e: T) => boolean) {
const idx = arr.findIndex(predicate);
if (idx !== -1) arr.splice(idx, 1);
}
removeFromArray(SettingsPlugin.customEntries, e => e.key === "vencord_startup_timings");
removeFromArray(SettingsPlugin.settingsSectionMap, entry => entry[1] === "vencord_startup_timings");
},

View file

@ -123,3 +123,8 @@ export function isEquicordSupport(userId: string | null | undefined): boolean {
const member = GuildMemberStore.getMember(GUILD_ID, userId);
return member?.roles?.includes(EQUICORD_HELPERS) || false;
}
export function removeFromArray<T>(arr: T[], predicate: (e: T) => boolean) {
const idx = arr.findIndex(predicate);
if (idx !== -1) arr.splice(idx, 1);
}

View file

@ -627,71 +627,72 @@ function patchFactory(moduleId: PropertyKey, originalFactory: AnyModuleFactory):
if (IS_DEV) {
diffErroredPatch(code, lastCode, lastCode.match(replacement.match)!);
}
if (markedAsPatched) {
patchedBy.delete(patch.plugin);
}
if (patch.group) {
logger.warn(`Undoing patch group ${patch.find} by ${patch.plugin} because replacement ${replacement.match} errored`);
if (IS_COMPANION_TEST)
reporterData.failedPatches.undoingPatchGroup.push({
...patch,
id: moduleId
});
code = previousCode;
patchedFactory = previousFactory;
break;
}
code = lastCode;
patchedFactory = lastFactory;
}
}
if (!patch.all) {
patches.splice(i--, 1);
if (markedAsPatched) {
patchedBy.delete(patch.plugin);
}
if (patch.group) {
logger.warn(`Undoing patch group ${patch.find} by ${patch.plugin} because replacement ${replacement.match} errored`);
if (IS_COMPANION_TEST)
reporterData.failedPatches.undoingPatchGroup.push({
...patch,
id: moduleId
});
code = previousCode;
patchedFactory = previousFactory;
break;
}
code = lastCode;
patchedFactory = lastFactory;
}
}
patchedFactory[SYM_ORIGINAL_FACTORY] = originalFactory;
if (IS_DEV && patchedFactory !== originalFactory) {
originalFactory[SYM_PATCHED_SOURCE] = patchedSource;
originalFactory[SYM_PATCHED_BY] = patchedBy;
if (!patch.all) {
patches.splice(i--, 1);
}
return patchedFactory as PatchedModuleFactory;
}
function diffErroredPatch(code: string, lastCode: string, match: RegExpMatchArray) {
const changeSize = code.length - lastCode.length;
patchedFactory[SYM_ORIGINAL_FACTORY] = originalFactory;
// Use 200 surrounding characters of context
const start = Math.max(0, match.index! - 200);
const end = Math.min(lastCode.length, match.index! + match[0].length + 200);
// (changeSize may be negative)
const endPatched = end + changeSize;
const context = lastCode.slice(start, end);
const patchedContext = code.slice(start, endPatched);
// Inline require to avoid including it in !IS_DEV builds
const diff = (require("diff") as typeof import("diff")).diffWordsWithSpace(context, patchedContext);
let fmt = "%c %s ";
const elements: string[] = [];
for (const d of diff) {
const color = d.removed
? "red"
: d.added
? "lime"
: "grey";
fmt += "%c%s";
elements.push("color:" + color, d.value);
}
logger.errorCustomFmt(...Logger.makeTitle("white", "Before"), context);
logger.errorCustomFmt(...Logger.makeTitle("white", "After"), patchedContext);
const [titleFmt, ...titleElements] = Logger.makeTitle("white", "Diff");
logger.errorCustomFmt(titleFmt + fmt, ...titleElements, ...elements);
if (IS_DEV && patchedFactory !== originalFactory) {
originalFactory[SYM_PATCHED_SOURCE] = patchedSource;
originalFactory[SYM_PATCHED_BY] = patchedBy;
}
return patchedFactory as PatchedModuleFactory;
}
function diffErroredPatch(code: string, lastCode: string, match: RegExpMatchArray) {
const changeSize = code.length - lastCode.length;
// Use 200 surrounding characters of context
const start = Math.max(0, match.index! - 200);
const end = Math.min(lastCode.length, match.index! + match[0].length + 200);
// (changeSize may be negative)
const endPatched = end + changeSize;
const context = lastCode.slice(start, end);
const patchedContext = code.slice(start, endPatched);
// Inline require to avoid including it in !IS_DEV builds
const diff = (require("diff") as typeof import("diff")).diffWordsWithSpace(context, patchedContext);
let fmt = "%c %s ";
const elements: string[] = [];
for (const d of diff) {
const color = d.removed
? "red"
: d.added
? "lime"
: "grey";
fmt += "%c%s";
elements.push("color:" + color, d.value);
}
logger.errorCustomFmt(...Logger.makeTitle("white", "Before"), context);
logger.errorCustomFmt(...Logger.makeTitle("white", "After"), patchedContext);
const [titleFmt, ...titleElements] = Logger.makeTitle("white", "Diff");
logger.errorCustomFmt(titleFmt + fmt, ...titleElements, ...elements);
}