Skip to content

Commit

Permalink
[settings] Add Experiments as a core feature
Browse files Browse the repository at this point in the history
  • Loading branch information
pylixonly committed Mar 26, 2024
1 parent 5169bfa commit c675172
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/i18n/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"MACHINE_ID": "Machine ID",
"MANUFACTURER": "Manufacturer",
"MESSAGE": "Message",
"MISCELLANEOUS": "Miscellaneous",
"MODAL_THEME_REFETCHED": "Theme refetched",
"MODAL_THEME_REFETCHED_DESC": "A reload is required to see the changes. Do you want to reload now?",
"MODAL_UNPROXIED_PLUGIN_DESC": "The plugin you are trying to install has not been proxied/verified by staffs. Are you sure you want to continue?",
Expand All @@ -77,6 +78,8 @@
"SAFE_MODE_NOTICE_PLUGINS": "You are in Safe Mode, so plugins cannot be loaded. Disable any misbehaving plugins, then return to Normal Mode from the General settings page.",
"SAFE_MODE_NOTICE_THEMES": "You are in Safe Mode, meaning themes have been temporarily disabled. {enabled, select, true {If a theme appears to be causing the issue, you can press below to disable it persistently.} false {}}",
"SEARCH": "Search",
"SETTINGS_ACTIVATE_DISCORD_EXPERIMENTS": "Activate Discord Experiments",
"SETTINGS_ACTIVATE_DISCORD_EXPERIMENTS_DESC": "Warning: Messing with this feature may lead to account termination. We are not responsible for what you do with this feature.",
"STACK_TRACE": "Stack Trace",
"SUCCESSFULLY_INSTALLED": "Successfully installed",
"THEME_REFETCH_FAILED": "Failed to refetch theme!",
Expand Down
12 changes: 12 additions & 0 deletions src/core/ui/settings/pages/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ export default function General() {
}}
/>
</TableRowGroup>
<TableRowGroup title={Strings.MISCELLANEOUS}>
<TableSwitchRow
label={Strings.SETTINGS_ACTIVATE_DISCORD_EXPERIMENTS}
subLabel={Strings.SETTINGS_ACTIVATE_DISCORD_EXPERIMENTS_DESC}
icon={<TableRow.Icon source={getAssetIDByName("ic_progress_wrench_24px")} />}
value={settings.enableDiscordDeveloperSettings}
onValueChange={(v: boolean) => {
settings.enableDiscordDeveloperSettings = v;
}}
/>
</TableRowGroup>

</Stack>
</ScrollView>
);
Expand Down
15 changes: 14 additions & 1 deletion src/lib/metro/filters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { instead } from "@lib/api/patcher";


export type MetroModules = { [id: string]: any; };
export type PropIntellisense<P extends string | symbol> = Record<P, any> & Record<PropertyKey, any>;
export type PropsFinder = <T extends string | symbol>(...props: T[]) => PropIntellisense<T>;
Expand Down Expand Up @@ -42,6 +41,20 @@ const onModuleCheck = (exports: any) => {
}
});
}

if (exports?.default?.constructor?.displayName === "DeveloperExperimentStore") {
exports.default = new Proxy(exports.default, {
get: (target, property, receiver) => {
if (property === "isDeveloper") {
// Hopefully won't explode accessing it here :3
const { settings } = require("@lib/settings");
return settings.enableDiscordDeveloperSettings ?? false;
}

return Reflect.get(target, property, receiver);
}
});
}
};

function maybeInitializeModule(id: string) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createFileBackend, createMMKVBackend, createStorage, wrapSync } from "@
export interface Settings {
debuggerUrl: string;
developerSettings: boolean;
enableDiscordDeveloperSettings: boolean;
safeMode?: {
enabled: boolean;
currentThemeId?: string;
Expand Down

0 comments on commit c675172

Please sign in to comment.