[skip ci] Avoid loading old preferences every time if not needed
This commit is contained in:
1 parent
ab246e8080
commit
6d9117a2a0
2 files changed
+10
-7
No files matched your search
@@ -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/),
|
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).
|
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
|
## [0.38.2] - 2025-05-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import "pkg:/source/utils/RegistryUtils.bs"
|
import "pkg:/source/utils/RegistryUtils.bs"
|
||||||
|
import "pkg:/source/utils/StringUtils.bs"
|
||||||
import "pkg:/source/utils/Types.bs"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
function Init()
|
function Init()
|
||||||
@@ -93,23 +94,21 @@ function MigrateExistingPreferences(userPrefs as object) as boolean
|
|||||||
isDirty = false
|
isDirty = false
|
||||||
|
|
||||||
' v0 -> v1
|
' v0 -> v1
|
||||||
|
if ValidInt(userPrefs.__version) = 0
|
||||||
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
|
instances = RegistryUtils.Read(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||||
if instances <> invalid
|
if not StringUtils.IsNullOrEmpty(instances)
|
||||||
currentInstance = userPrefs["invidious.instance"]
|
currentInstance = userPrefs["invidious.instance"]
|
||||||
if currentInstance = invalid or currentInstance = ""
|
if StringUtils.IsNullOrEmpty(currentInstance)
|
||||||
instances = ParseJson(instances)
|
instances = ParseJson(instances)
|
||||||
if instances.Count() > 0
|
if IsArray(instances) and instances.Count() > 0
|
||||||
instance = instances[0]
|
instance = instances[0]
|
||||||
if instance <> invalid and instance <> ""
|
if not StringUtils.IsNullOrEmpty(instance)
|
||||||
userPrefs["invidious.instance"] = instance
|
userPrefs["invidious.instance"] = instance
|
||||||
isDirty = true
|
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
|
RegistryUtils.Delete(RegistryUtils.INVIDIOUS_INSTANCES)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
if ValidInt(userPrefs.__version) = 0
|
|
||||||
userPrefs.__version = 1
|
userPrefs.__version = 1
|
||||||
isDirty = true
|
isDirty = true
|
||||||
end if
|
end if
|
||||||
|
|||||||
Reference in new issue
Block a user