Prevent crash when localstorage contains invalide network preset

This commit is contained in:
Ivan Danyliuk 2018-11-06 13:02:38 +01:00
parent 7dc84bc5c7
commit 1e09bf634d
No known key found for this signature in database
GPG Key ID: 97ED33CE024E1DBF

View File

@ -94,13 +94,19 @@ func (n *NetworkSelector) descriptionBlock() *vecty.HTML {
func (n *NetworkSelector) networkOptions() vecty.List {
var options vecty.List
for name := range n.networks {
options = append(options, elem.Option(
currentName := "none"
if n.current != nil {
currentName = n.current.Name
}
opt := elem.Option(
vecty.Markup(
vecty.Property("value", name),
vecty.Property("selected", n.current.Name == "data/"+name), // TODO(divan): get rid of "data"
vecty.Property("selected", currentName == "data/"+name), // TODO(divan): get rid of "data"
),
vecty.Text(name),
))
)
options = append(options, opt)
}
return options
}