Skip to content

Commit

Permalink
made customCategories persistent
Browse files Browse the repository at this point in the history
  • Loading branch information
DJSchaffner committed Feb 21, 2024
1 parent c381f99 commit aed92e1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ local L = addonBetterBags:GetModule('Localization')

local debug = false
local frame = CreateFrame("Frame", nil)
local customCategories = {}
-------------------------------------------------------
local function printChat(message)
if debug == true then
Expand All @@ -27,7 +26,7 @@ end

local function updateCategories()
-- Wipe custom categories since we can't retrieve deleted set from itemRack (Except maybe store duplicate of sets and check last version of it)
for category, _ in pairs(customCategories) do
for category, _ in pairs(CustomCategories) do
-- @TODO completely remove label as custom category from BetterBags
categories:WipeCategory(L:G(category))
printChat("Wiped category '" .. L:G(category) .. "'")
Expand Down Expand Up @@ -72,12 +71,22 @@ local function updateCategories()
label = "Sets: ".. table.concat(sets, ", ")
end

customCategories[L:G(label)] = true
CustomCategories[L:G(label)] = true
categories:AddItemToCategory(item, L:G(label))
-- printChat("Added item '" .. id .. "' to '" .. label .. "' category")
end
end

local function initCategories()
-- Prepare stored variable
if CustomCategories == nil then
CustomCategories = {}
end

printChat("ItemRack Loaded..")
printChat("Initializing Categories..")
updateCategories()
end

local function itemRackUpdated(event, eventData)
printChat(event)
Expand All @@ -90,9 +99,6 @@ frame:SetScript("OnEvent", function(self, event, addon, ...)
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_SAVED", itemRackUpdated)
ItemRack:RegisterExternalEventListener("ITEMRACK_SET_DELETED", itemRackUpdated)


printChat("ItemRack Loaded..")
printChat("Initializing Categories..")
updateCategories()
initCategories()
end
end)

0 comments on commit aed92e1

Please sign in to comment.