|
1 | 1 | local MAJOR_VERSION = "LibGetFrame-1.0"
|
2 |
| -local MINOR_VERSION = 7 |
| 2 | +local MINOR_VERSION = 8 |
3 | 3 | if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
|
4 | 4 | local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
|
5 | 5 | if not lib then return end
|
@@ -86,11 +86,16 @@ local function ScanFrames(depth, frame, ...)
|
86 | 86 | ScanFrames(depth, ...)
|
87 | 87 | end
|
88 | 88 |
|
89 |
| -local function ScanForUnitFrames() |
90 |
| - C_Timer.After(1, function() |
| 89 | +local function ScanForUnitFrames(noDelay) |
| 90 | + if noDelay then |
91 | 91 | wipe(GetFramesCache)
|
92 | 92 | ScanFrames(0, UIParent)
|
93 |
| - end) |
| 93 | + else |
| 94 | + C_Timer.After(1, function() |
| 95 | + wipe(GetFramesCache) |
| 96 | + ScanFrames(0, UIParent) |
| 97 | + end) |
| 98 | + end |
94 | 99 | end
|
95 | 100 |
|
96 | 101 | local function isFrameFiltered(name, ignoredFrames)
|
@@ -150,19 +155,19 @@ local defaultOptions = {
|
150 | 155 | }
|
151 | 156 |
|
152 | 157 | local GetFramesCacheListener
|
153 |
| -lib.Init = function() |
| 158 | +lib.Init = function(noDelay) |
154 | 159 | GetFramesCacheListener = CreateFrame("Frame")
|
155 | 160 | GetFramesCacheListener:RegisterEvent("PLAYER_REGEN_DISABLED")
|
156 | 161 | GetFramesCacheListener:RegisterEvent("PLAYER_REGEN_ENABLED")
|
157 | 162 | GetFramesCacheListener:RegisterEvent("PLAYER_ENTERING_WORLD")
|
158 | 163 | GetFramesCacheListener:RegisterEvent("GROUP_ROSTER_UPDATE")
|
159 | 164 | GetFramesCacheListener:SetScript("OnEvent", ScanForUnitFrames)
|
160 | 165 |
|
161 |
| - ScanForUnitFrames() |
| 166 | + ScanForUnitFrames(noDelay) |
162 | 167 | end
|
163 | 168 |
|
164 | 169 | function lib.GetUnitFrame(target, opt)
|
165 |
| - if not GetFramesCacheListener then lib.Init() end |
| 170 | + if not GetFramesCacheListener then lib.Init(true) end |
166 | 171 | opt = opt or {}
|
167 | 172 | setmetatable(opt, { __index = defaultOptions })
|
168 | 173 |
|
|
0 commit comments