Skip to content

Commit

Permalink
fix lastrunversion migration + make whats new show per user
Browse files Browse the repository at this point in the history
  • Loading branch information
cewert committed Dec 6, 2023
1 parent 6f70a06 commit 81ef7e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
18 changes: 10 additions & 8 deletions source/Main.bs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ sub Main (args as dynamic) as void
m.wasMigrated = false
runGlobalMigrations()
runRegistryUserMigrations()
' update LastRunVersion now that migrations are finished
showWhatsNew = false
' update global LastRunVersion now that migrations are finished
if m.global.app.version <> m.global.app.lastRunVersion
showWhatsNew = true
set_setting("LastRunVersion", m.global.app.version)
end if
if m.wasMigrated then printRegistry()
Expand Down Expand Up @@ -74,11 +72,15 @@ sub Main (args as dynamic) as void
end if
end if

' Show the Whats New popup
if showWhatsNew and m.global.session.user.settings["load.allowwhatsnew"]
dialog = createObject("roSGNode", "WhatsNewDialog")
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
' has the current user ran this version before?
if not versionChecker(m.global.session.user.settings.lastRunVersion, m.global.app.version)
set_user_setting("LastRunVersion", m.global.app.version)
' show what's new popup
if m.global.session.user.settings["load.allowwhatsnew"]
dialog = createObject("roSGNode", "WhatsNewDialog")
m.scene.dialog = dialog
m.scene.dialog.observeField("buttonSelected", m.port)
end if
end if

' Handle input messages
Expand Down
2 changes: 1 addition & 1 deletion source/migrations.bs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ sub runRegistryUserMigrations()
' app versions < 2.0.0 didn't save LastRunVersion at the user level
' fall back to using the apps lastRunVersion
lastRunVersion = m.global.app.lastRunVersion
registry_write("LastRunVersion", m.global.app.version, section)
registry_write("LastRunVersion", lastRunVersion, section)
end if

' BASE_MIGRATION
Expand Down
5 changes: 1 addition & 4 deletions source/utils/session.bs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ namespace session

' grab lastRunVersion for this user
lastRunVersion = get_user_setting("LastRunVersion")
if isValid(lastRunVersion) and lastRunVersion = m.global.app.version
' Don't update the registry, only update the global session
if isValid(lastRunVersion)
session.user.Update("LastRunVersion", lastRunVersion)
else
set_user_setting("LastRunVersion", m.global.app.version)
end if

' update user session settings with values from registry
Expand Down

0 comments on commit 81ef7e2

Please sign in to comment.