mirror of
				https://github.com/redphx/better-xcloud.git
				synced 2025-11-04 07:54:05 +01:00 
			
		
		
		
	Fix calling definition.ready() multiple times
This commit is contained in:
		
							
								
								
									
										2
									
								
								dist/better-xcloud.pretty.user.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/better-xcloud.pretty.user.js
									
									
									
									
										vendored
									
									
								
							@@ -1167,7 +1167,7 @@ class BaseSettingsStorage {
 | 
			
		||||
  this.storage = window.localStorage, this.storageKey = storageKey;
 | 
			
		||||
  for (let [_, setting] of Object.entries(definitions)) {
 | 
			
		||||
   if (typeof setting.requiredVariants === "string") setting.requiredVariants = [setting.requiredVariants];
 | 
			
		||||
   setting.ready && setting.ready.call(this, setting);
 | 
			
		||||
   if (setting.ready) setting.ready.call(this, setting), delete setting.ready;
 | 
			
		||||
  }
 | 
			
		||||
  this.definitions = definitions, this._settings = null;
 | 
			
		||||
 }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								dist/better-xcloud.user.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/better-xcloud.user.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -28,7 +28,10 @@ export class BaseSettingsStorage<T extends AnyPref> {
 | 
			
		||||
            }
 | 
			
		||||
            */
 | 
			
		||||
 | 
			
		||||
            setting.ready && setting.ready.call(this, setting);
 | 
			
		||||
            if (setting.ready) {
 | 
			
		||||
                setting.ready.call(this, setting);
 | 
			
		||||
                delete setting.ready;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        this.definitions = definitions;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import { BypassServers } from "@/enums/bypass-servers";
 | 
			
		||||
import { GlobalPref, StorageKey, type GlobalPrefTypeMap } from "@/enums/pref-keys";
 | 
			
		||||
import { GlobalPref, StorageKey } from "@/enums/pref-keys";
 | 
			
		||||
import { UserAgentProfile } from "@/enums/user-agent";
 | 
			
		||||
import { type SettingDefinition } from "@/types/setting-definition";
 | 
			
		||||
import { type SettingDefinition, type SettingDefinitions } from "@/types/setting-definition";
 | 
			
		||||
import { BX_FLAGS } from "../bx-flags";
 | 
			
		||||
import { STATES, AppInterface } from "../global";
 | 
			
		||||
import { CE } from "../html";
 | 
			
		||||
@@ -71,7 +71,7 @@ function getSupportedCodecProfiles() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class GlobalSettingsStorage extends BaseSettingsStorage<GlobalPref> {
 | 
			
		||||
    private static readonly DEFINITIONS: Record<keyof GlobalPrefTypeMap, SettingDefinition> = {
 | 
			
		||||
    private static readonly DEFINITIONS: SettingDefinitions<GlobalPref> = {
 | 
			
		||||
        [GlobalPref.VERSION_LAST_CHECK]: {
 | 
			
		||||
            default: 0,
 | 
			
		||||
        },
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import { StreamPref, StorageKey, type StreamPrefTypeMap, type PrefTypeMap } from "@/enums/pref-keys";
 | 
			
		||||
import { StreamPref, StorageKey, type PrefTypeMap } from "@/enums/pref-keys";
 | 
			
		||||
import { DeviceVibrationMode, StreamPlayerType, StreamVideoProcessing, VideoPowerPreference, VideoRatio, VideoPosition, StreamStat, StreamStatPosition } from "@/enums/pref-values";
 | 
			
		||||
import { STATES } from "../global";
 | 
			
		||||
import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table";
 | 
			
		||||
@@ -6,7 +6,7 @@ import { MkbMappingDefaultPresetId } from "../local-db/mkb-mapping-presets-table
 | 
			
		||||
import { t } from "../translation";
 | 
			
		||||
import { BaseSettingsStorage } from "./base-settings-storage";
 | 
			
		||||
import { CE } from "../html";
 | 
			
		||||
import type { SettingActionOrigin, SettingDefinition } from "@/types/setting-definition";
 | 
			
		||||
import type { SettingActionOrigin, SettingDefinitions } from "@/types/setting-definition";
 | 
			
		||||
import { BxIcon } from "../bx-icon";
 | 
			
		||||
import { GameSettingsStorage } from "./game-settings-storage";
 | 
			
		||||
import { BxLogger } from "../bx-logger";
 | 
			
		||||
@@ -15,7 +15,7 @@ import { ControllerShortcutDefaultId } from "../local-db/controller-shortcuts-ta
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
 | 
			
		||||
    static readonly DEFINITIONS: Record<keyof StreamPrefTypeMap, SettingDefinition> = {
 | 
			
		||||
    static readonly DEFINITIONS: SettingDefinitions<StreamPref> = {
 | 
			
		||||
        [StreamPref.DEVICE_VIBRATION_MODE]: {
 | 
			
		||||
            requiredVariants: 'full',
 | 
			
		||||
            label: t('device-vibration'),
 | 
			
		||||
@@ -132,7 +132,7 @@ export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
 | 
			
		||||
            max: 4,
 | 
			
		||||
            params: {
 | 
			
		||||
                hideSlider: true,
 | 
			
		||||
                customTextValue(value) {
 | 
			
		||||
                customTextValue(value: any) {
 | 
			
		||||
                    value = parseInt(value);
 | 
			
		||||
                    return (value === 0) ? t('off') : value.toString();
 | 
			
		||||
                },
 | 
			
		||||
@@ -302,7 +302,7 @@ export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
 | 
			
		||||
            params: {
 | 
			
		||||
                size: 0,
 | 
			
		||||
            },
 | 
			
		||||
            ready: setting => {
 | 
			
		||||
            ready: (setting: any) => {
 | 
			
		||||
                // Remove Battery option in unsupported browser
 | 
			
		||||
                const multipleOptions = (setting as any).multipleOptions;
 | 
			
		||||
                if (!STATES.browser.capabilities.batteryApi) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user