diff --git a/lib/discord/src/modules/settings/_internal.ts b/lib/discord/src/modules/settings/_internal.ts index 8e8a669..ad2efc1 100644 --- a/lib/discord/src/modules/settings/_internal.ts +++ b/lib/discord/src/modules/settings/_internal.ts @@ -4,16 +4,15 @@ import type { SettingsSection, } from '.' -export const sData = [ - // Sections to splice in the SettingsOverviewScreen - {}, - // SETTING_RENDERER_CONFIG settings - {}, - false, -] as [ - sections: Record, - config: Record, - loaded: boolean, -] +// Sections to splice in the SettingsOverviewScreen +export const sSections: Record = {} +// SETTING_RENDERER_CONFIG settings +export const sConfig: Record = {} + +export const sData = { + loaded: false, +} as { + loaded: boolean +} export const sSubscriptions = new Set() diff --git a/lib/discord/src/modules/settings/index.ts b/lib/discord/src/modules/settings/index.ts index 09f6a5f..717b49d 100644 --- a/lib/discord/src/modules/settings/index.ts +++ b/lib/discord/src/modules/settings/index.ts @@ -3,7 +3,7 @@ import { noop } from '@revenge-mod/utils/callback' import { findInTree } from '@revenge-mod/utils/tree' import { Constants } from '../../common' import { RootNavigationRef } from '../main_tabs_v2' -import { sData, sSubscriptions } from './_internal' +import { sConfig, sData, sSections, sSubscriptions } from './_internal' import type { NavigationState, PartialState } from '@react-navigation/core' import type { DiscordModules } from '../../types' @@ -16,7 +16,7 @@ export type SettingsModulesLoadedSubscription = () => void * Checks if the settings modules are loaded. */ export function isSettingsModulesLoaded() { - return sData[2] + return sData.loaded } /** @@ -50,9 +50,9 @@ export function onSettingsModulesLoaded( * @returns A function to unregister the settings section. */ export function registerSettingsSection(key: string, section: SettingsSection) { - sData[0][key] = section + sSections[key] = section return () => { - delete sData[0][key] + delete sSections[key] } } @@ -64,9 +64,9 @@ export function registerSettingsSection(key: string, section: SettingsSection) { * @returns A function to unregister the settings item. */ export function registerSettingsItem(key: string, item: SettingsItem) { - sData[1][key] = item + sConfig[key] = item return () => { - delete sData[1][key] + delete sConfig[key] } } @@ -77,9 +77,9 @@ export function registerSettingsItem(key: string, item: SettingsItem) { * @returns A function to unregister the settings items. */ export function registerSettingsItems(record: Record) { - Object.assign(sData[1], record) + Object.assign(sConfig, record) return () => { - for (const key in record) delete sData[1][key] + for (const key in record) delete sConfig[key] } } @@ -91,7 +91,7 @@ export function registerSettingsItems(record: Record) { * @returns A function to remove the settings item from the section. */ export function addSettingsItemToSection(key: string, item: string) { - const section = sData[0][key] + const section = sSections[key] if (!section) throw new Error(`Section "${key}" does not exist`) const newLength = section.settings.push(item) diff --git a/src/plugins/start/settings/index.ts b/src/plugins/start/settings/index.ts index aa233e5..0f22b1a 100644 --- a/src/plugins/start/settings/index.ts +++ b/src/plugins/start/settings/index.ts @@ -1,4 +1,9 @@ -import { sData, sSubscriptions } from '@revenge-mod/discord/_/modules/settings' +import { + sConfig, + sData, + sSections, + sSubscriptions, +} from '@revenge-mod/discord/_/modules/settings' import { onSettingsModulesLoaded } from '@revenge-mod/discord/modules/settings' import { byName, byProps } from '@revenge-mod/modules/finders/filters' import { waitForModules } from '@revenge-mod/modules/finders/wait' @@ -45,7 +50,7 @@ registerPlugin( // We don't ever need to call this again sSubscriptions.clear() - sData[2] = true + sData.loaded = true let ORIGINAL_RENDERER_CONFIG = SettingRendererConfig.SETTING_RENDERER_CONFIG @@ -57,7 +62,7 @@ registerPlugin( get: () => ({ ...ORIGINAL_RENDERER_CONFIG, - ...sData[1], + ...sConfig, }) as Record, set: v => (ORIGINAL_RENDERER_CONFIG = v), }, @@ -70,7 +75,7 @@ registerPlugin( exports => { unsubSOS() - const customSections = sData[0] + const customSections = sSections after(exports as { default: FC }, 'default', tree => { const {