fix Vencord Settings section being added multiple times

This commit is contained in:
Vendicated 2024-05-14 21:18:43 +02:00
parent a54b55edad
commit 719c6140f3
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -154,6 +154,8 @@ export default definePlugin({
if (settingsLocation === "bottom") return firstChild === "LOGOUT"; if (settingsLocation === "bottom") return firstChild === "LOGOUT";
if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG"; if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG";
if (!header) return;
const names = { const names = {
top: i18n.Messages.USER_SETTINGS, top: i18n.Messages.USER_SETTINGS,
aboveNitro: i18n.Messages.BILLING_SETTINGS, aboveNitro: i18n.Messages.BILLING_SETTINGS,
@ -163,8 +165,12 @@ export default definePlugin({
return header === names[settingsLocation]; return header === names[settingsLocation];
}, },
patchedSettings: new WeakSet(),
addSettings(elements: any[], element: { header?: string; settings: string[]; }, sectionTypes: Record<string, unknown>) { addSettings(elements: any[], element: { header?: string; settings: string[]; }, sectionTypes: Record<string, unknown>) {
if (!this.isRightSpot(element)) return; if (this.patchedSettings.has(elements) || !this.isRightSpot(element)) return;
this.patchedSettings.add(elements);
elements.push(...this.makeSettingsCategories(sectionTypes)); elements.push(...this.makeSettingsCategories(sectionTypes));
}, },