diff --git a/src/api/settingsInjection.js b/src/api/settingsInjection.js index 1a9261c..80380db 100644 --- a/src/api/settingsInjection.js +++ b/src/api/settingsInjection.js @@ -4,7 +4,12 @@ import webpack from "./webpack"; const settingsSym = Symbol("__settings"); -const settingsView = webpack.find(m => m.default && m.default.displayName === "SettingsView"); +// super secret value that shouldnt be exposed, used internally to avoid section conflicts and the like +const ovrwrtSctnSym: symbol = Symbol("__overwriteSection"); + +const settingsView = webpack.find( + (m) => m.default && m.default.displayName === "SettingsView" +); type getPredicateSectionsEntry = | { @@ -22,7 +27,7 @@ type getPredicateSectionsEntry = function patch(args: mixed, ret: getPredicateSectionsEntry[]) { const processedEntries = window.demon[settingsSym].entries.map((e) => ({ - section: "DEMON_SETTINGS_LOADER_" + e.name, + section: e[ovrwrtSctnSym] ?? "DEMON_SETTINGS_LOADER_" + e.name, label: e.name, element: e.component, })); @@ -63,9 +68,18 @@ function unregisterSettingsEntry(name: string) { s.entries = s.entries.filter((e) => e.name !== name); } -function registerSettingsEntry(name: string, component: Function): () => void { - window.demon[settingsSym].entries.push({ name, component }); +function registerSettingsEntry(name: string, section: string, component: Function): () => void { + let entry = { name, component }; + if (section) + entry[ovrwrtSctnSym] = section; + window.demon[settingsSym].entries.push(entry); return () => unregisterSettingsEntry(name); } -export default { init, unInit, registerSettingsEntry, unregisterSettingsEntry }; +export default { + init, + unInit, + registerSettingsEntry, + unregisterSettingsEntry, + ovrwrtSctnSymm: ovrwrtSctnSym, +}; diff --git a/src/init.js b/src/init.js index 55337ca..062f17e 100644 --- a/src/init.js +++ b/src/init.js @@ -46,8 +46,8 @@ async function init(obj: Object): Promise { }, }; commands.init(obj); - plugins.init(obj); settingsInj.init(); + plugins.init(obj); } export default init;