mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-05 20:58:27 +02:00
Add FeatureGates
This commit is contained in:
@@ -23,7 +23,7 @@ export const BxExposed = {
|
||||
|
||||
let supportedInputTypes = titleInfo.details.supportedInputTypes;
|
||||
|
||||
if (BX_FLAGS.ForceNativeMkbTitles.includes(titleInfo.details.productId)) {
|
||||
if (BX_FLAGS.ForceNativeMkbTitles?.includes(titleInfo.details.productId)) {
|
||||
supportedInputTypes.push(InputType.MKB);
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ type BxFlags = Partial<{
|
||||
UseDevTouchLayout: boolean;
|
||||
|
||||
ForceNativeMkbTitles: string[];
|
||||
FeatureGates: {[key: string]: boolean} | null,
|
||||
}>
|
||||
|
||||
// Setup flags
|
||||
@@ -21,9 +22,10 @@ const DEFAULT_FLAGS: BxFlags = {
|
||||
UseDevTouchLayout: false,
|
||||
|
||||
ForceNativeMkbTitles: [],
|
||||
FeatureGates: null,
|
||||
}
|
||||
|
||||
export const BX_FLAGS = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
||||
export const BX_FLAGS: BxFlags = Object.assign(DEFAULT_FLAGS, window.BX_FLAGS || {});
|
||||
try {
|
||||
delete window.BX_FLAGS;
|
||||
} catch (e) {}
|
||||
|
20
src/utils/feature-gates.ts
Normal file
20
src/utils/feature-gates.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BX_FLAGS } from "./bx-flags";
|
||||
import { getPref, PrefKey } from "./preferences";
|
||||
|
||||
export let FeatureGates: {[key: string]: boolean} = {
|
||||
'PwaPrompt': false,
|
||||
};
|
||||
|
||||
// Disable context menu in Home page
|
||||
if (getPref(PrefKey.UI_HOME_CONTEXT_MENU_DISABLED)) {
|
||||
FeatureGates['EnableHomeContextMenu'] = false;
|
||||
}
|
||||
|
||||
// Disable chat feature
|
||||
if (getPref(PrefKey.BLOCK_SOCIAL_FEATURES)) {
|
||||
FeatureGates['EnableGuideChatTab'] = false;
|
||||
}
|
||||
|
||||
if (BX_FLAGS.FeatureGates) {
|
||||
FeatureGates = Object.assign(BX_FLAGS.FeatureGates, FeatureGates);
|
||||
}
|
@@ -9,6 +9,7 @@ import { STATES } from "@utils/global";
|
||||
import { getPreferredServerRegion } from "@utils/region";
|
||||
import { GamePassCloudGallery } from "./gamepass-gallery";
|
||||
import { InputType } from "./bx-exposed";
|
||||
import { FeatureGates } from "./feature-gates";
|
||||
|
||||
enum RequestType {
|
||||
XCLOUD = 'xcloud',
|
||||
@@ -440,7 +441,7 @@ class XcloudInterceptor {
|
||||
|
||||
let overrideMkb: boolean | null = null;
|
||||
|
||||
if (getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on' || BX_FLAGS.ForceNativeMkbTitles.includes(STATES.currentStream.titleInfo!.details.productId)) {
|
||||
if (getPref(PrefKey.NATIVE_MKB_ENABLED) === 'on' || BX_FLAGS.ForceNativeMkbTitles?.includes(STATES.currentStream.titleInfo!.details.productId)) {
|
||||
overrideMkb = true;
|
||||
}
|
||||
|
||||
@@ -578,14 +579,8 @@ export function interceptHttpRequests() {
|
||||
const response = await NATIVE_FETCH(request, init);
|
||||
const json = await response.json();
|
||||
|
||||
const overrideTreatments: {[key: string]: boolean} = {};
|
||||
|
||||
if (getPref(PrefKey.UI_HOME_CONTEXT_MENU_DISABLED)) {
|
||||
overrideTreatments['EnableHomeContextMenu'] = false;
|
||||
}
|
||||
|
||||
for (const key in overrideTreatments) {
|
||||
json.exp.treatments[key] = overrideTreatments[key]
|
||||
for (const key in FeatureGates) {
|
||||
json.exp.treatments[key] = FeatureGates[key]
|
||||
}
|
||||
|
||||
response.json = () => Promise.resolve(json);
|
||||
|
Reference in New Issue
Block a user