Fix empty invidious instance in preferences

This commit is contained in:
Brahim Hadriche committed 2024-03-04 13:03:59 -05:00
1 parent 13bb21c1f7
commit 1c8d075e87
3 files changed
+13 -2

No files matched your search

@@ -1,5 +1,7 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/Invidious/InvidiousService.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
function Init()
@@ -7,6 +9,7 @@ function Init()
m.top.itemSpacings = [8]
m.button = m.top.findNode("button")
m.button.text = Invidious.DEFAULT_INSTANCE
AdjustButtonLabel(m.button)
m.button.observeField("buttonSelected", FuncName(OpenInvidiousInstanceSettings))
@@ -74,5 +77,12 @@ function OnValueChange() as void
return
end if
m.preferences[m.key] = m.top.value
value = m.top.value
m.preferences[m.key] = value
if StringUtils.IsNullOrEmpty(value)
m.button.text = Invidious.DEFAULT_INSTANCE
else
m.button.text = value
end if
end function