diff --git a/CHANGELOG.md b/CHANGELOG.md index bcd9a73b..d361de38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Nothing worth mentioning yet. + ## [0.38.2] - 2025-05-22 ### Added diff --git a/playlet-lib/src/components/Services/Preferences/Preferences.bs b/playlet-lib/src/components/Services/Preferences/Preferences.bs index 88922a90..23fb043c 100644 --- a/playlet-lib/src/components/Services/Preferences/Preferences.bs +++ b/playlet-lib/src/components/Services/Preferences/Preferences.bs @@ -1,4 +1,5 @@ import "pkg:/source/utils/RegistryUtils.bs" +import "pkg:/source/utils/StringUtils.bs" import "pkg:/source/utils/Types.bs" function Init() @@ -93,23 +94,21 @@ function MigrateExistingPreferences(userPrefs as object) as boolean isDirty = false ' v0 -> v1 - instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES) - if instances <> invalid - currentInstance = userPrefs["invidious.instance"] - if currentInstance = invalid or currentInstance = "" - instances = ParseJson(instances) - if instances.Count() > 0 - instance = instances[0] - if instance <> invalid and instance <> "" - userPrefs["invidious.instance"] = instance - isDirty = true + if ValidInt(userPrefs.__version) = 0 + instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES) + if not StringUtils.IsNullOrEmpty(instances) + currentInstance = userPrefs["invidious.instance"] + if StringUtils.IsNullOrEmpty(currentInstance) + instances = ParseJson(instances) + if IsArray(instances) and instances.Count() > 0 + instance = instances[0] + if not StringUtils.IsNullOrEmpty(instance) + userPrefs["invidious.instance"] = instance + end if end if end if + RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES) end if - RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES) - end if - - if ValidInt(userPrefs.__version) = 0 userPrefs.__version = 1 isDirty = true end if