Skip to content

Commit

Permalink
Fix What's New version checker
Browse files Browse the repository at this point in the history
  • Loading branch information
1hitsong committed Nov 21, 2024
1 parent 837b336 commit 99954fe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
5 changes: 2 additions & 3 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ sub Main (args as dynamic) as void
set_user_setting("LastRunVersion", m.global.app.version)
end if

' Bypass What's New popup if deep linking arguments were passed
' Has the current user run this version before?
usersLastRunVersion = m.global.session.user.settings.lastRunVersion
' has the current user ran this version before?
if not isValid(usersLastRunVersion) or not versionChecker(m.global.session.user.settings.lastRunVersion, m.global.app.version)
if ChannelVersionUpdated(usersLastRunVersion)
set_user_setting("LastRunVersion", m.global.app.version)
' show what's new popup
if m.global.session.user.settings["load.allowwhatsnew"]
Expand Down
8 changes: 1 addition & 7 deletions source/ShowScenes.bs
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,7 @@ function CreateSigninGroup(user = "", profileImageUri = "")
saveCredentials = group.findNode("saveCredentials")

quickConnect = group.findNode("quickConnect")
' Quick Connect only supported for server version 10.8+ right now...
if versionChecker(m.global.session.server.version, "10.8.0")
' Add option for Quick Connect
quickConnect.observeField("selected", port)
else
quickConnect.visible = false
end if
quickConnect.observeField("selected", port)

button = group.findNode("submit")
button.observeField("selected", port)
Expand Down
4 changes: 4 additions & 0 deletions source/static/whatsNew/1.1.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
{
"description": "Create Show Overview Content setting",
"author": "1hitsong"
},
{
"description": "Fix What's New version checker",
"author": "1hitsong"
}
]
34 changes: 16 additions & 18 deletions source/utils/misc.bs
Original file line number Diff line number Diff line change
Expand Up @@ -409,31 +409,29 @@ function getMinutes(ticks) as integer
end function

'
' Returns whether or not a version number (e.g. 10.7.7) is greater or equal
' to some minimum version allowed (e.g. 10.8.0)
function versionChecker(versionToCheck as string, minVersionAccepted as string)
leftHand = CreateObject("roLongInteger")
rightHand = CreateObject("roLongInteger")

regEx = CreateObject("roRegex", "\.", "")
version = regEx.Split(versionToCheck)
' Returns whether or not the channel version number is higher than the passed version number
function ChannelVersionUpdated(versionToCheck)
if not isValidAndNotEmpty(versionToCheck) then return true

version = versionToCheck.split(".")
if version.Count() < 3
for i = version.Count() to 3 step 1
version.AddTail("0")
version.push("0")
end for
end if

minVersion = regEx.Split(minVersionAccepted)
if minVersion.Count() < 3
for i = minVersion.Count() to 3 step 1
minVersion.AddTail("0")
end for
end if
currentVersion = m.global.app.version.split(".")

leftHand = (version[0].ToInt() * 10000) + (version[1].ToInt() * 100) + (version[2].ToInt() * 10)
rightHand = (minVersion[0].ToInt() * 10000) + (minVersion[1].ToInt() * 100) + (minVersion[2].ToInt() * 10)
' Check Major version
if currentVersion[0].ToInt() > version[0].ToInt() then return true

return leftHand >= rightHand
' Check Minor version
if currentVersion[1].ToInt() > version[1].ToInt() then return true

' Check Patch version
if currentVersion[2].ToInt() > version[2].ToInt() then return true

return false
end function

function findNodeBySubtype(node, subtype)
Expand Down

0 comments on commit 99954fe

Please sign in to comment.