@@ -4,8 +4,10 @@ local LibStub = _G.LibStub
44local C_LFGList = _G .C_LFGList
55local ipairs = _G .ipairs
66
7-
87local name = ...
8+
9+ local currentPatch = select (4 , GetBuildInfo ())
10+
911--- @class LazyCurve
1012local LazyCurve = LibStub (' AceAddon-3.0' ):GetAddon (name )
1113if not LazyCurve then return end
@@ -18,42 +20,55 @@ ModuleUtil.moduleInfoTables = {}
1820--- @param module LazyCurveModule
1921--- @return LazyCurveActivityTable_enriched
2022function ModuleUtil :GetLatestModuleRaid (module )
21- return self :GetModuleInfoTable (module )[1 ]
23+ return self :GetModuleInfoTable (module )[1 ]
2224end
2325
2426--- @param module LazyCurveModule
2527--- @return boolean
2628function ModuleUtil :ModuleHasLatestRaid (module )
27- return LazyCurve .CURRENT_EXPANSION == module .EXPANSION and module .type == LazyCurve .MODULE_TYPE_RAID
29+ return LazyCurve .CURRENT_EXPANSION == module .EXPANSION and module .type == LazyCurve .MODULE_TYPE_RAID
2830end
2931
3032--- @param module LazyCurveModule
3133--- @param groupId number
3234--- @return LazyCurveActivityTable_enriched | false
3335function ModuleUtil :GetModuleInfoTableByActivityGroup (module , groupId )
34- for _ , activityTable in ipairs (self :GetModuleInfoTable (module )) do
35- if activityTable .groupId == groupId then
36- return activityTable
37- end
38- end
39- return false
36+ for _ , activityTable in ipairs (self :GetModuleInfoTable (module )) do
37+ if activityTable .groupId == groupId then
38+ return activityTable
39+ end
40+ end
41+ return false
4042end
4143
4244--- @param module LazyCurveModule
4345--- @return LazyCurveActivityTable_enriched[]
4446function ModuleUtil :GetModuleInfoTable (module )
45- local moduleName = module .moduleName
46- if not self .moduleInfoTables [moduleName ] then
47- --- @class LazyCurveActivityTable_enriched []: LazyCurveActivityTable []
48- local infoTable = module :GetInfoTable ()
49- for _ , activityTable in ipairs (infoTable ) do
50- local localName , _ = C_LFGList .GetActivityGroupInfo (activityTable .groupId )
51- activityTable .longName = localName or activityTable .shortName
52- activityTable .module = module
53- activityTable .isLatest = self :ModuleHasLatestRaid (module ) and infoTable [1 ] == activityTable
54- end
55- self .moduleInfoTables [moduleName ] = infoTable
56- end
57-
58- return self .moduleInfoTables [moduleName ]
59- end
47+ local moduleName = module .moduleName
48+ if not self .moduleInfoTables [moduleName ] then
49+ local firstValidTable = nil
50+ --- @class LazyCurveActivityTable_enriched []: LazyCurveActivityTable []
51+ local infoTable = module :GetInfoTable ()
52+ for i , activityTable in ipairs (infoTable ) do
53+ if activityTable .minPatch and currentPatch < activityTable .minPatch then
54+ -- Skip activities that are not available in the current patch
55+ infoTable [i ] = nil
56+ else
57+ firstValidTable = firstValidTable or activityTable
58+ local localName , _ = C_LFGList .GetActivityGroupInfo (activityTable .groupId )
59+ activityTable .longName = localName or activityTable .shortName
60+ activityTable .module = module
61+ activityTable .isLatest = self :ModuleHasLatestRaid (module ) and firstValidTable == activityTable
62+ end
63+ end
64+ -- Remove nil entries from the table
65+ for i = # infoTable , 1 , - 1 do
66+ if not infoTable [i ] then
67+ table.remove (infoTable , i )
68+ end
69+ end
70+ self .moduleInfoTables [moduleName ] = infoTable
71+ end
72+
73+ return self .moduleInfoTables [moduleName ]
74+ end
0 commit comments