fix Vencord Settings section being added multiple times

This commit is contained in:
Vendicated 2024-05-14 21:18:43 +02:00 committed by Nuckyz
parent 4209bfd3aa
commit 5ba5eca1a1
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -154,6 +154,8 @@ export default definePlugin({
if (settingsLocation === "bottom") return firstChild === "LOGOUT";
if (settingsLocation === "belowActivity") return firstChild === "CHANGELOG";
if (!header) return;
const names = {
top: i18n.Messages.USER_SETTINGS,
aboveNitro: i18n.Messages.BILLING_SETTINGS,
@ -163,8 +165,12 @@ export default definePlugin({
return header === names[settingsLocation];
},
patchedSettings: new WeakSet(),
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));
},