Show Settings button in header when not signed in

This commit is contained in:
redphx 2024-07-15 17:04:04 +07:00
parent d41fd22a47
commit 7409956616
5 changed files with 31 additions and 17 deletions

View File

@ -92,8 +92,8 @@ if (BX_FLAGS.SafariWorkaround && document.readyState !== 'loading') {
throw new Error('[Better xCloud] Executing workaround for Safari');
}
// Automatically reload the page when running into the "We are sorry..." error message
window.addEventListener('load', e => {
// Automatically reload the page when running into the "We are sorry..." error message
window.setTimeout(() => {
if (document.body.classList.contains('legacyBackground')) {
// Has error message -> reload page
@ -102,18 +102,29 @@ window.addEventListener('load', e => {
window.location.reload(true);
}
}, 3000);
});
// Hide "Play with Friends" skeleton section
if (getPref(PrefKey.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS)) {
document.addEventListener('readystatechange', e => {
if (document.readyState === 'interactive') {
const $parent = document.querySelector('div[class*=PlayWithFriendsSkeleton]')?.closest('div[class*=HomePage-module]') as HTMLElement;
$parent && ($parent.style.display = 'none');
}
})
}
document.addEventListener('readystatechange', e => {
if (document.readyState !== 'interactive') {
return;
}
STATES.isSignedIn = (window as any).xbcUser.isSignedIn;
if (STATES.isSignedIn) {
// Preload Remote Play
getPref(PrefKey.REMOTE_PLAY_ENABLED) && BX_FLAGS.PreloadRemotePlay && RemotePlay.preload();
} else {
// Show Settings button in the header when not signed
HeaderSection.watchHeader();
}
// Hide "Play with Friends" skeleton section
if (getPref(PrefKey.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS)) {
const $parent = document.querySelector('div[class*=PlayWithFriendsSkeleton]')?.closest('div[class*=HomePage-module]') as HTMLElement;
$parent && ($parent.style.display = 'none');
}
})
window.BX_EXPOSED = BxExposed;
@ -342,9 +353,6 @@ function main() {
BxLogger.info('startPointerServer', 'Port', STATES.pointerServerPort.toString());
}
// Preload Remote Play
getPref(PrefKey.REMOTE_PLAY_ENABLED) && BX_FLAGS.PreloadRemotePlay && RemotePlay.preload();
// Show wait time in game card
getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup();
}

View File

@ -162,7 +162,7 @@ export function setupSettingsUi() {
}
// "Stream settings" button
topButtons.push(createButton({
(STATES.supportedRegion && STATES.isSignedIn) && topButtons.push(createButton({
label: t('stream-settings'),
icon: BxIcon.STREAM_SETTINGS,
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
@ -228,6 +228,11 @@ export function setupSettingsUi() {
// Render settings
for (let groupLabel in SETTINGS_UI) {
// Don't render other settings when not signed in
if (groupLabel !== 'Better xCloud' && (!STATES.supportedRegion || !STATES.isSignedIn)) {
continue;
}
const $group = CE('span', {'class': 'bx-settings-group-label'}, groupLabel);
// Render note

View File

@ -28,7 +28,7 @@ type BxStates = {
serverRegions: any;
selectedRegion: any;
gsToken: string;
isSignedIn: boolean;
isPlaying: boolean;
appContext: any | null;

View File

@ -17,6 +17,7 @@ export const STATES: BxStates = {
serverRegions: {},
selectedRegion: {},
gsToken: '',
isSignedIn: false,
isPlaying: false,
appContext: {},

View File

@ -128,7 +128,7 @@ export class Preferences {
},
[PrefKey.SERVER_BYPASS_RESTRICTION]: {
label: t('bypass-region-restriction'),
note: t('use-this-at-your-own-risk'),
note: '⚠️ ' + t('use-this-at-your-own-risk'),
default: 'off',
options: Object.assign({
'off': t('off'),