Refactor settings

This commit is contained in:
Brahim Hadriche committed 2025-05-22 17:41:47 -04:00
1 parent 68a4f9fade
commit becb8b04f5
9 files changed
+47 -20

No files matched your search

+4
View File
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- German translation
### Changed
- Settings: Added a "backend" section, and removed backend selection from Playback to avoid confusion
### Fixed
- Display issue in playlist view
@@ -17,7 +17,7 @@ function SearchSuggestionsTask(input as object) as object
suggestions: []
}
else
backend = preferencesNode["playback.backend"]
backend = preferencesNode["backend.selected"]
if backend = "playlet"
searchSuggestsions = InnertubeService.SearchSuggestions(q, m.top.cancellation)
else
@@ -70,18 +70,18 @@ namespace Invidious
if m.preferences = invalid
m.preferences = m.invidiousNode.preferences
end if
instance = m.preferences["invidious.instance"]
if not StringUtils.IsNullOrEmpty(instance)
return instance
backend = m.preferences["backend.selected"]
if backend = "invidious"
instance = m.preferences["invidious.instance"]
if not StringUtils.IsNullOrEmpty(instance)
return instance
end if
end if
instance = DEFAULT_INSTANCE
if instance.StartsWith("http://127.0.0.1:8888")
address = m.invidiousNode.webServer@.GetServerAddress()
instance = instance.Replace("http://127.0.0.1:8888", address)
end if
address = m.invidiousNode.webServer@.GetServerAddress()
instance = instance.Replace("http://127.0.0.1:8888", address)
return instance
end function
@@ -143,7 +143,23 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
isDirty = true
end if
if userPrefs.__version = 3
if IsString(userPrefs["playback.backend"])
backend = userPrefs["playback.backend"]
userPrefs.Delete("playback.backend")
userPrefs["backend.selected"] = backend
end if
userPrefs.__version = 4
isDirty = true
end if
' TODO:P2 handle case where saved preferences version is higher than current version (e.g. user downgraded)
#if DEBUG
if userPrefs.__version <> m.top.__version
throw "Preferences version mismatch. Expected: " + m.top.__version + ", found: " + userPrefs.__version
end if
#end if
return isDirty
end function
@@ -5,7 +5,7 @@
user prefs saved need to be migrated. If the version is less than the
current version, a migration is needed.
-->
<field id="__version" type="integer" value="2" />
<field id="__version" type="integer" value="4" />
<field id="prefsModel" type="array" />
<field id="preferenceFields" type="assocarray" />
<function name="GetUserPreferences" />
@@ -20,7 +20,7 @@ function VideoContentTask(input as object) as object
service = new Invidious.InvidiousService(invidiousNode)
backend = preferencesNode["playback.backend"]
backend = preferencesNode["backend.selected"]
if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(contentNode.videoId, {
"cancellation": m.top.cancellation
@@ -25,7 +25,7 @@ function VideoContentTaskDev(input as object) as object
backgroundPoster.uri = `${instance}/vi/${videoId}/maxresdefault.jpg`
backend = preferencesNode["playback.backend"]
backend = preferencesNode["backend.selected"]
if backend = "playlet"
metadata = InnertubeService.GetVideoMetadata(videoId, { cancellation: m.top.cancellation })
else
@@ -16,7 +16,7 @@ function VideoQueueViewContentTask(input as object) as object
index = MathUtils.Clamp(input.index - 2, 0, videoNodes.Count() - 1)
backend = preferencesNode["playback.backend"]
backend = preferencesNode["backend.selected"]
requestOptions = {
cacheSeconds: 8640000 ' 100 days
+14 -7
View File
@@ -27,21 +27,28 @@
visibility: "web",
svelteComponent: "EditQualityControl",
},
],
},
{
displayText: "Backend",
key: "backend",
description: "Backend preferences",
children: [
{
displayText: "Backend",
key: "playback.backend",
description: "The backend used for fetching video data. The Playlet backend is experimental",
displayText: "Selected backend",
key: "backend.selected",
description: "The backend used for browsing and playing videos.",
type: "radio",
defaultValue: "playlet",
options: [
{
displayText: "Invidious",
value: "invidious",
},
{
displayText: "Playlet (local)",
value: "playlet",
},
{
displayText: "Invidious",
value: "invidious",
},
],
},
],