From 94bcf102313720bbac1213fb271ba3a3e30b2b70 Mon Sep 17 00:00:00 2001 From: Charles Ewert Date: Thu, 1 Jun 2023 23:08:56 -0400 Subject: [PATCH] update startover var and session if saver serverurl has no connection at s tartup --- source/ShowScenes.brs | 6 +++++- source/utils/session.bs | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/ShowScenes.brs b/source/ShowScenes.brs index 237e5441..91d95788 100644 --- a/source/ShowScenes.brs +++ b/source/ShowScenes.brs @@ -5,7 +5,11 @@ function LoginFlow(startOver = false as boolean) serverUrl = get_setting("server") if isValid(serverUrl) 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 startOver = true print "No previous server connection saved to registry" diff --git a/source/utils/session.bs b/source/utils/session.bs index ed323e6d..45a10fca 100644 --- a/source/utils/session.bs +++ b/source/utils/session.bs @@ -59,21 +59,23 @@ namespace session end sub ' 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 - if value = "" then return + if value = "" then return false session.server.Update("url", value) - session.server.Populate() - end sub + return session.server.Populate() + end function ' 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 - 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 myServerInfo = ServerInfo() ' validate data returned from API - if myServerInfo.id = invalid then return + if myServerInfo.id = invalid then return false ' make copy of global server session tmpSessionServer = m.global.session.server ' update the temp array @@ -93,7 +95,8 @@ namespace session tmpSessionServer.AddReplace("isLocalHTTPS", isLocalServerHTTPS) ' update global server session using the temp array session.Update("server", tmpSessionServer) - end sub + return true + end function end namespace namespace user