-
Notifications
You must be signed in to change notification settings - Fork 0
SelfVersion
SelfVersion.lua: detects whether an addon's own version changed since the last saved session.
Keeps a capped rolling history of seen versions, detects a change against the last-seen one, and backfills history for an install that predates the tracking.
Limit: This can only ever detect "my own version changed since the last time this addon saved its settings".
Signature: store is your settings table, passed fresh on every call (same reasoning as the module manager functions: if your addon's settings table can be swapped at runtime, a cached reference would go stale). Returns wasUpdated, previousVersion.
opts (all optional):
| Field | Default | Meaning |
|---|---|---|
versionField |
"last_version" |
Where the last-seen version is stored |
historyField |
"version_history" |
Where the rolling history array is stored |
maxHistory |
3 |
How many versions to keep before trimming the oldest |
local wasUpdated, previousVersion = LibAPH.CheckSelfVersion(MyAddon.settings, MyAddon.version)
if wasUpdated then
d(string.format("MyAddon updated from %s to %s.", previousVersion, MyAddon.version))
endAn install upgrading from before this tracking existed (it has a last_version but no version_history yet) gets that old version backfilled as history's first entry automatically, rather than starting history with a gap.