Skip to content

Commit

Permalink
more state fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nnoggie committed Sep 6, 2024
1 parent 99557de commit e517106
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions WagoUI/frames/components/profileSelectionList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function addon:CreateProfileSelectionList(parent, frameWidth, frameHeight, check
line.checkBox:SetSwitchFunction(
function()
info.enabled = not info.enabled
local res = addon.db.selectedWagoDataResolution
local res = addon.db.selectedWagoDataResolution or addon.resolutions.defaultValue
addon.db.introImportState[res][lap.moduleName].checked = info.enabled
updateEnabledState()
checkedCallback()
Expand Down Expand Up @@ -143,7 +143,7 @@ function addon:CreateProfileSelectionList(parent, frameWidth, frameHeight, check
line.nameLabel:SetText(labelText)

line.textEntry:SetText(info.profileKey)
local res = addon.db.selectedWagoDataResolution
local res = addon.db.selectedWagoDataResolution or addon.resolutions.defaultValue
addon.db.introImportState[res][lap.moduleName].checked = info.enabled
if updated and (loaded or canEnable) then
line.textEntry:Show()
Expand Down
2 changes: 1 addition & 1 deletion WagoUI/frames/introFrame/directProfilesPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local function createPage()
header:SetPoint("TOPLEFT", page, "TOPLEFT", 0, -15)

local checkboxDefaultValue = true
local res = addon.db.selectedWagoDataResolution
local res = addon.db.selectedWagoDataResolution or addon.resolutions.defaultValue
for _, data in pairs(addon.db.introImportState[res]) do
if not data.checked then
checkboxDefaultValue = false
Expand Down
11 changes: 5 additions & 6 deletions WagoUI/frames/introFrame/installPage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ local page, installButton, header, simpleList, hasSkipped
---@param needEnableAddons boolean If we need to enable some addons before we can install
---@param introImportState table<string, IntroImportState>
local setupInstallButton = function(enabled, needEnableAddons, introImportState)
local res = addon.db.selectedWagoDataResolution
header:SetText("")
if not enabled then
installButton:SetEnabled(false)
Expand All @@ -25,7 +24,7 @@ local setupInstallButton = function(enabled, needEnableAddons, introImportState)
installButton:SetEnabled(true)
installButton:SetClickFunction(
function()
for moduleName, data in pairs(introImportState[res]) do
for moduleName, data in pairs(introImportState) do
local lap = LAP:GetModule(moduleName)
if data.checked and not lap:isLoaded() and LAP:CanEnableAnyAddOn(lap.addonNames) then
LAP:EnableAddOns(lap.addonNames)
Expand All @@ -49,7 +48,7 @@ local setupInstallButton = function(enabled, needEnableAddons, introImportState)
installButton:SetEnabled(false)
addon.state.isImporting = true
local countOperations = 0
for moduleName, data in pairs(introImportState[res]) do
for moduleName, data in pairs(introImportState) do
local lap = LAP:GetModule(moduleName)
if data.checked and lap:isLoaded() and lap:isUpdated() then
countOperations = countOperations + 1
Expand All @@ -59,12 +58,12 @@ local setupInstallButton = function(enabled, needEnableAddons, introImportState)
addon.copyHelper:SmartShow(addon.frames.mainFrame, 0, 0, L["Importing profiles..."])
addon:Async(
function()
for moduleName, data in pairs(introImportState[res]) do
for moduleName, data in pairs(introImportState) do
local lap = LAP:GetModule(moduleName)
if data.checked and lap:isLoaded() and lap:isUpdated() then
lap:importProfile(data.profile, data.profileKey, true)
if lap.conflictingAddons then
LAP:DisableConflictingAddons(lap.conflictingAddons, introImportState[res])
LAP:DisableConflictingAddons(lap.conflictingAddons, introImportState)
end
addon:AddonPrint(string.format(L["Imported %s: %s"], data.profileKey, moduleName))
addon:StoreImportedProfileData(data.profileMetadata.lastUpdatedAt, moduleName, data.profileKey)
Expand Down Expand Up @@ -100,7 +99,7 @@ local updatePage = function(updatedData)
end
local numChecked = 0
local numNeedEnable = 0
local res = addon.db.selectedWagoDataResolution
local res = addon.db.selectedWagoDataResolution or addon.resolutions.defaultValue
---@type table<string, IntroImportState>
local introState = addon.db.introImportState[res]
local checkedEntries = {}
Expand Down
4 changes: 3 additions & 1 deletion WagoUI/modules/wagoData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ function addon:SetupWagoData()
local source = WagoUI_Storage[db.selectedWagoData]
addon.wagoData = {}
local newIntroImportState = {}
for _, entry in pairs(addon.resolutions.entries) do
newIntroImportState[entry.value] = {}
end
for resolution, modules in pairs(source.profileKeys) do
newIntroImportState[resolution] = {}
addon.wagoData[resolution] = {}
for moduleName, moduleData in pairs(modules) do
if type(moduleData) == "string" then
Expand Down

0 comments on commit e517106

Please sign in to comment.