Efficient stuff

This commit is contained in:
jimiatnymbl 2021-12-26 14:03:59 -07:00
parent 897338b9dc
commit 450448ac96
2 changed files with 15 additions and 4 deletions

View File

@ -412,6 +412,9 @@ sub SaveServerList()
'Save off this server to our list of saved servers for easier navigation between servers
server = get_setting("server")
saved = get_setting("saved_servers")
if server <> invalid
server = LCase(server)'Saved server data is always lowercase
end if
entryCount = 0
addNewEntry = true
savedServers = { serverList: [] }
@ -420,7 +423,7 @@ sub SaveServerList()
entryCount = savedServers.serverList.Count()
if savedServers.serverList <> invalid and entryCount > 0
for each item in savedServers.serverList
if item.baseUrl = LCase(server) 'Saved server data is always lowercase
if item.baseUrl = server
addNewEntry = false
exit for
end if
@ -440,11 +443,14 @@ end sub
sub DeleteFromServerList(urlToDelete)
saved = get_setting("saved_servers")
if urlToDelete <> invalid
urlToDelete = LCase(urlToDelete)
end if
if saved <> invalid
savedServers = ParseJson(saved)
newServers = { serverList: [] }
for each item in savedServers.serverList
if item.baseUrl <> LCase(urlToDelete) 'saved server data is always lowercase
if item.baseUrl <> urlToDelete
newServers.serverList.Push(item)
end if
end for

View File

@ -143,11 +143,14 @@ function CreateSigninGroup(user = "")
'Load in any saved server data and see if we can just log them in...
server = get_setting("server")
if server <> invalid
server = LCase(server)'Saved server data is always lowercase
end if
saved = get_setting("saved_servers")
if saved <> invalid
savedServers = ParseJson(saved)
for each item in savedServers.serverList
if item.baseUrl = LCase(server) and item.username <> invalid and item.password <> invalid
if item.baseUrl = server and item.username <> invalid and item.password <> invalid
get_token(item.username, item.password)
if get_setting("active_user") <> invalid
return "true"
@ -369,13 +372,15 @@ sub UpdateSavedServerList()
return
end if
server = LCase(server)'Saved server data is always lowercase
saved = get_setting("saved_servers")
if saved <> invalid
savedServers = ParseJson(saved)
if savedServers.serverList <> invalid and savedServers.serverList.Count() > 0
newServers = { serverList: [] }
for each item in savedServers.serverList
if item.baseUrl = LCase(server) ' Saved server data is always lowercase
if item.baseUrl = server
item.username = username
item.password = password
end if