diff --git a/WeakAuras/Features.lua b/WeakAuras/Features.lua index c2f440418a..9ef30afa2d 100644 --- a/WeakAuras/Features.lua +++ b/WeakAuras/Features.lua @@ -30,7 +30,7 @@ end ---@param id string function Features:Enable(id) - if self.__feats[id] then + if self:Exists(id) and not self.__feats[id].enabled then self.__feats[id].enabled = true if self.__feats[id].persist then Private.db.features[id] = true @@ -41,7 +41,7 @@ end ---@param id string function Features:Disable(id) - if self.__feats[id] then + if self:Exists(id) and self.__feats[id].enabled then self.__feats[id].enabled = false if self.__feats[id].persist then Private.db.features[id] = false @@ -50,6 +50,18 @@ function Features:Disable(id) end end +-- enable persisted features from the db +function Features:Hydrate() + for id, enabled in (Private.db.features) do + if not self:Exists(id) then + Private.db.features[id] = nil + end + if enabled then + self:Enable(id) + end + end +end + ---@param feature feature function Features:Register(feature) if not self.__feats[feature.id] then diff --git a/WeakAuras/WeakAuras.lua b/WeakAuras/WeakAuras.lua index cffbc34406..7dfe917ba0 100644 --- a/WeakAuras/WeakAuras.lua +++ b/WeakAuras/WeakAuras.lua @@ -1171,6 +1171,7 @@ function Private.Login(initialTime, takeNewSnapshots) Private.Pause(); db.features = db.features or {} + Private.Features:Hydrate() if db.history then local histRepo = WeakAuras.LoadFromArchive("Repository", "history") local migrationRepo = WeakAuras.LoadFromArchive("Repository", "migration")