update startover var and session if saver serverurl has no connection at s tartup

This commit is contained in:
Charles Ewert 2023-06-01 23:08:56 -04:00
parent d5b7e0ebdb
commit 94bcf10231
2 changed files with 16 additions and 9 deletions

View File

@ -5,7 +5,11 @@ function LoginFlow(startOver = false as boolean)
serverUrl = get_setting("server") serverUrl = get_setting("server")
if isValid(serverUrl) if isValid(serverUrl)
print "Previous server connection saved to registry" print "Previous server connection saved to registry"
session.server.UpdateURL(serverUrl) startOver = not session.server.UpdateURL(serverUrl)
if startOver
print "Could not connect to previously saved server."
session.server.Delete()
end if
else else
startOver = true startOver = true
print "No previous server connection saved to registry" print "No previous server connection saved to registry"

View File

@ -59,21 +59,23 @@ namespace session
end sub end sub
' Add or update the jellyfin server URL from the global server session array (m.global.session.server) ' Add or update the jellyfin server URL from the global server session array (m.global.session.server)
sub UpdateURL(value as string) ' Returns a boolean based on if a connection to the Jellyfin server was made
function UpdateURL(value as string) as boolean
' validate parameters ' validate parameters
if value = "" then return if value = "" then return false
session.server.Update("url", value) session.server.Update("url", value)
session.server.Populate() return session.server.Populate()
end sub end function
' Use the saved server url to populate the global server session array (m.global.session.server) ' Use the saved server url to populate the global server session array (m.global.session.server)
sub Populate() ' Returns a boolean based on if a connection to the Jellyfin server was made
function Populate() as boolean
' validate server url ' validate server url
if m.global.session.server.url = invalid or m.global.session.server.url = "" then return if m.global.session.server.url = invalid or m.global.session.server.url = "" then return false
' get server info using API ' get server info using API
myServerInfo = ServerInfo() myServerInfo = ServerInfo()
' validate data returned from API ' validate data returned from API
if myServerInfo.id = invalid then return if myServerInfo.id = invalid then return false
' make copy of global server session ' make copy of global server session
tmpSessionServer = m.global.session.server tmpSessionServer = m.global.session.server
' update the temp array ' update the temp array
@ -93,7 +95,8 @@ namespace session
tmpSessionServer.AddReplace("isLocalHTTPS", isLocalServerHTTPS) tmpSessionServer.AddReplace("isLocalHTTPS", isLocalServerHTTPS)
' update global server session using the temp array ' update global server session using the temp array
session.Update("server", tmpSessionServer) session.Update("server", tmpSessionServer)
end sub return true
end function
end namespace end namespace
namespace user namespace user