Minor fixes

This commit is contained in:
redphx 2024-07-30 18:06:40 +07:00
parent 9fad2914ac
commit 361ce057b7
4 changed files with 9 additions and 17 deletions

View File

@ -19,7 +19,7 @@ export class ProductDetailsPage {
private static shortcutTimeoutId: number | null = null;
static injectShortcutButton() {
if (!AppInterface || BX_FLAGS.DeviceInfo!.deviceType !== 'android') {
if (!AppInterface || BX_FLAGS.DeviceInfo.deviceType !== 'android') {
return;
}

View File

@ -1,4 +1,4 @@
type BxFlags = Partial<{
type BxFlags = {
CheckForUpdate: boolean;
EnableXcloudLogging: boolean;
SafariWorkaround: boolean;
@ -6,13 +6,11 @@ type BxFlags = Partial<{
ForceNativeMkbTitles: string[];
FeatureGates: {[key: string]: boolean} | null,
IsSupportedTvBrowser: boolean,
DeviceInfo: Partial<{
DeviceInfo: {
deviceType: 'android' | 'android-tv' | 'webos' | 'unknown',
userAgent?: string,
}>,
}>
}
}
// Setup flags
const DEFAULT_FLAGS: BxFlags = {
@ -33,8 +31,8 @@ try {
delete window.BX_FLAGS;
} catch (e) {}
if (!BX_FLAGS.DeviceInfo!.userAgent) {
BX_FLAGS.DeviceInfo!.userAgent = window.navigator.userAgent;
if (!BX_FLAGS.DeviceInfo.userAgent) {
BX_FLAGS.DeviceInfo.userAgent = window.navigator.userAgent;
}
export const NATIVE_FETCH = window.fetch;

View File

@ -457,7 +457,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
[PrefKey.UI_CONTROLLER_FRIENDLY]: {
label: t('controller-friendly-ui'),
default: BX_FLAGS.DeviceInfo!.deviceType !== 'unknown',
default: BX_FLAGS.DeviceInfo.deviceType !== 'unknown',
},
[PrefKey.UI_LAYOUT]: {
@ -512,7 +512,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
[PrefKey.USER_AGENT_PROFILE]: {
label: t('user-agent-profile'),
note: '⚠️ ' + t('unexpected-behavior'),
default: BX_FLAGS.DeviceInfo!.deviceType === 'android-tv' ? UserAgentProfile.VR_OCULUS : 'default',
default: (BX_FLAGS.DeviceInfo.deviceType === 'android-tv' || BX_FLAGS.DeviceInfo.deviceType === 'webos') ? UserAgentProfile.VR_OCULUS : 'default',
options: {
[UserAgentProfile.DEFAULT]: t('default'),
[UserAgentProfile.WINDOWS_EDGE]: 'Edge + Windows',

View File

@ -1,5 +1,4 @@
import { UserAgentProfile } from "@enums/user-agent";
import { BX_FLAGS } from "./bx-flags";
type UserAgentConfig = {
profile: UserAgentProfile,
@ -120,11 +119,6 @@ export class UserAgent {
let newUserAgent = UserAgent.get(profile);
// Pretend to be Tizen TV
if (BX_FLAGS.IsSupportedTvBrowser) {
newUserAgent += ` SmartTV ${SMART_TV_UNIQUE_ID}`;
}
// Clear data of navigator.userAgentData, force xCloud to detect browser based on navigator.userAgent
if ('userAgentData' in window.navigator) {
(window.navigator as any).orgUserAgentData = (window.navigator as any).userAgentData;