mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 16:17:20 +02:00
Fix calling definition.ready() multiple times
This commit is contained in:
parent
706665713f
commit
0ef8fe18ac
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;
|
this.storage = window.localStorage, this.storageKey = storageKey;
|
||||||
for (let [_, setting] of Object.entries(definitions)) {
|
for (let [_, setting] of Object.entries(definitions)) {
|
||||||
if (typeof setting.requiredVariants === "string") setting.requiredVariants = [setting.requiredVariants];
|
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;
|
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;
|
this.definitions = definitions;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { BypassServers } from "@/enums/bypass-servers";
|
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 { 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 { BX_FLAGS } from "../bx-flags";
|
||||||
import { STATES, AppInterface } from "../global";
|
import { STATES, AppInterface } from "../global";
|
||||||
import { CE } from "../html";
|
import { CE } from "../html";
|
||||||
@ -71,7 +71,7 @@ function getSupportedCodecProfiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class GlobalSettingsStorage extends BaseSettingsStorage<GlobalPref> {
|
export class GlobalSettingsStorage extends BaseSettingsStorage<GlobalPref> {
|
||||||
private static readonly DEFINITIONS: Record<keyof GlobalPrefTypeMap, SettingDefinition> = {
|
private static readonly DEFINITIONS: SettingDefinitions<GlobalPref> = {
|
||||||
[GlobalPref.VERSION_LAST_CHECK]: {
|
[GlobalPref.VERSION_LAST_CHECK]: {
|
||||||
default: 0,
|
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 { DeviceVibrationMode, StreamPlayerType, StreamVideoProcessing, VideoPowerPreference, VideoRatio, VideoPosition, StreamStat, StreamStatPosition } from "@/enums/pref-values";
|
||||||
import { STATES } from "../global";
|
import { STATES } from "../global";
|
||||||
import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table";
|
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 { t } from "../translation";
|
||||||
import { BaseSettingsStorage } from "./base-settings-storage";
|
import { BaseSettingsStorage } from "./base-settings-storage";
|
||||||
import { CE } from "../html";
|
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 { BxIcon } from "../bx-icon";
|
||||||
import { GameSettingsStorage } from "./game-settings-storage";
|
import { GameSettingsStorage } from "./game-settings-storage";
|
||||||
import { BxLogger } from "../bx-logger";
|
import { BxLogger } from "../bx-logger";
|
||||||
@ -15,7 +15,7 @@ import { ControllerShortcutDefaultId } from "../local-db/controller-shortcuts-ta
|
|||||||
|
|
||||||
|
|
||||||
export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
|
export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
|
||||||
static readonly DEFINITIONS: Record<keyof StreamPrefTypeMap, SettingDefinition> = {
|
static readonly DEFINITIONS: SettingDefinitions<StreamPref> = {
|
||||||
[StreamPref.DEVICE_VIBRATION_MODE]: {
|
[StreamPref.DEVICE_VIBRATION_MODE]: {
|
||||||
requiredVariants: 'full',
|
requiredVariants: 'full',
|
||||||
label: t('device-vibration'),
|
label: t('device-vibration'),
|
||||||
@ -132,7 +132,7 @@ export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
|
|||||||
max: 4,
|
max: 4,
|
||||||
params: {
|
params: {
|
||||||
hideSlider: true,
|
hideSlider: true,
|
||||||
customTextValue(value) {
|
customTextValue(value: any) {
|
||||||
value = parseInt(value);
|
value = parseInt(value);
|
||||||
return (value === 0) ? t('off') : value.toString();
|
return (value === 0) ? t('off') : value.toString();
|
||||||
},
|
},
|
||||||
@ -302,7 +302,7 @@ export class StreamSettingsStorage extends BaseSettingsStorage<StreamPref> {
|
|||||||
params: {
|
params: {
|
||||||
size: 0,
|
size: 0,
|
||||||
},
|
},
|
||||||
ready: setting => {
|
ready: (setting: any) => {
|
||||||
// Remove Battery option in unsupported browser
|
// Remove Battery option in unsupported browser
|
||||||
const multipleOptions = (setting as any).multipleOptions;
|
const multipleOptions = (setting as any).multipleOptions;
|
||||||
if (!STATES.browser.capabilities.batteryApi) {
|
if (!STATES.browser.capabilities.batteryApi) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user