From aef5665cb52863eaa3b348c8d355ac48dff1fa6c Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 28 Jan 2025 00:47:45 +0100 Subject: [PATCH] Don't incorrectly set websites as user-defined just because initial player index was set --- src/common/interfaces/SettingsInterface.ts | 1 + .../src/components/SupportLevelIndicator.vue | 2 +- src/ext/lib/settings/SiteSettings.ts | 16 ++++++++++++---- src/ext/lib/video-data/PlayerData.ts | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/common/interfaces/SettingsInterface.ts b/src/common/interfaces/SettingsInterface.ts index cf5e4c4..4db1525 100644 --- a/src/common/interfaces/SettingsInterface.ts +++ b/src/common/interfaces/SettingsInterface.ts @@ -314,6 +314,7 @@ export interface SiteSettingsInterface { enableKeyboard: ExtensionEnvironmentSettingsInterface; enableUI: ExtensionEnvironmentSettingsInterface; // Lies! enableUI doesn't use 'theater' property (but uses the other two) + autocreated?: boolean; type?: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled' | 'unknown' | 'modified'; defaultType: 'official' | 'community' | 'user-defined' | 'testing' | 'officially-disabled' | 'unknown' | 'modified'; diff --git a/src/csui/src/components/SupportLevelIndicator.vue b/src/csui/src/components/SupportLevelIndicator.vue index 5b879f0..c9b7fb1 100644 --- a/src/csui/src/components/SupportLevelIndicator.vue +++ b/src/csui/src/components/SupportLevelIndicator.vue @@ -17,7 +17,7 @@ is geoblocked. -
+
Unknown
diff --git a/src/ext/lib/settings/SiteSettings.ts b/src/ext/lib/settings/SiteSettings.ts index f596f7d..e76b1f3 100644 --- a/src/ext/lib/settings/SiteSettings.ts +++ b/src/ext/lib/settings/SiteSettings.ts @@ -307,10 +307,18 @@ export class SiteSettings { * @param optionValue new value of option * @param reload whether we should trigger a reload in components that require it */ - async set(optionPath: string, optionValue: any, options: {reload?: boolean, noSave?: boolean} = {reload: false}) { - // if no settings exist for this site, create an empty object - if (!this.settings.active.sites[this.site]) { - this.settings.active.sites[this.site] = _cp(this.settings.active.sites['@empty']); + async set(optionPath: string, optionValue: any, options: {reload?: boolean, noSave?: boolean, scripted?: boolean} = {reload: false}) { + // if no settings exist for this site, create an empty object. + // If this function is not being called in response to user actin, + // create fake settings object. + if (options.scripted && !this.settings.active.sites[this.site]) { + this.settings.active.sites[this.site] = _cp(this.settings.active.sites['@global']); + this.settings.active.sites[this.site].autocreated = true; + this.settings.active.sites[this.site].type = 'unknown'; + } else { + if (!this.settings.active.sites[this.site] || this.settings.active.sites[this.site].autocreated) { + this.settings.active.sites[this.site] = _cp(this.settings.active.sites['@empty']); + } } const pathParts = optionPath.split('.'); diff --git a/src/ext/lib/video-data/PlayerData.ts b/src/ext/lib/video-data/PlayerData.ts index 84dbc06..85d63b6 100644 --- a/src/ext/lib/video-data/PlayerData.ts +++ b/src/ext/lib/video-data/PlayerData.ts @@ -718,7 +718,7 @@ class PlayerData { } else { bestCandidate.heuristics['autoMatch'] = true; if (this.siteSettings.data.playerAutoConfig?.initialIndex !== bestCandidate.index) { - this.siteSettings.set('playerAutoConfig.initialIndex', bestCandidate.index, {reload: false}); + this.siteSettings.set('playerAutoConfig.initialIndex', bestCandidate.index, {reload: false, scripted: true}); } }