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'); 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 => { window.addEventListener('load', e => {
// Automatically reload the page when running into the "We are sorry..." error message
window.setTimeout(() => { window.setTimeout(() => {
if (document.body.classList.contains('legacyBackground')) { if (document.body.classList.contains('legacyBackground')) {
// Has error message -> reload page // Has error message -> reload page
@ -102,18 +102,29 @@ window.addEventListener('load', e => {
window.location.reload(true); window.location.reload(true);
} }
}, 3000); }, 3000);
}); });
// Hide "Play with Friends" skeleton section document.addEventListener('readystatechange', e => {
if (getPref(PrefKey.UI_HIDE_SECTIONS).includes(UiSection.FRIENDS)) { if (document.readyState !== 'interactive') {
document.addEventListener('readystatechange', e => { return;
if (document.readyState === 'interactive') { }
const $parent = document.querySelector('div[class*=PlayWithFriendsSkeleton]')?.closest('div[class*=HomePage-module]') as HTMLElement;
$parent && ($parent.style.display = 'none'); 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; window.BX_EXPOSED = BxExposed;
@ -342,9 +353,6 @@ function main() {
BxLogger.info('startPointerServer', 'Port', STATES.pointerServerPort.toString()); 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 // Show wait time in game card
getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup(); getPref(PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME) && GameTile.setup();
} }

View File

@ -162,7 +162,7 @@ export function setupSettingsUi() {
} }
// "Stream settings" button // "Stream settings" button
topButtons.push(createButton({ (STATES.supportedRegion && STATES.isSignedIn) && topButtons.push(createButton({
label: t('stream-settings'), label: t('stream-settings'),
icon: BxIcon.STREAM_SETTINGS, icon: BxIcon.STREAM_SETTINGS,
style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE, style: ButtonStyle.FULL_WIDTH | ButtonStyle.FOCUSABLE,
@ -228,6 +228,11 @@ export function setupSettingsUi() {
// Render settings // Render settings
for (let groupLabel in SETTINGS_UI) { 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); const $group = CE('span', {'class': 'bx-settings-group-label'}, groupLabel);
// Render note // Render note

View File

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

View File

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

View File

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