mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-04 22:57:19 +02:00
Show Settings button in header when not signed in
This commit is contained in:
parent
d41fd22a47
commit
7409956616
36
src/index.ts
36
src/index.ts
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
2
src/types/index.d.ts
vendored
2
src/types/index.d.ts
vendored
@ -28,7 +28,7 @@ type BxStates = {
|
||||
serverRegions: any;
|
||||
selectedRegion: any;
|
||||
gsToken: string;
|
||||
|
||||
isSignedIn: boolean;
|
||||
|
||||
isPlaying: boolean;
|
||||
appContext: any | null;
|
||||
|
@ -17,6 +17,7 @@ export const STATES: BxStates = {
|
||||
serverRegions: {},
|
||||
selectedRegion: {},
|
||||
gsToken: '',
|
||||
isSignedIn: false,
|
||||
|
||||
isPlaying: false,
|
||||
appContext: {},
|
||||
|
@ -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'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user