Fix stale UI state and wrapper ordering
This commit is contained in:
@@ -28,17 +28,30 @@ module.enable = function(self)
|
||||
local format = clock == 24 and "%H:%M:%S" or "%I:%M:%S %p"
|
||||
local color = rgbhex({ rgb.r, rgb.g, rgb.b, rgb.a })
|
||||
|
||||
-- add hooks to each frame
|
||||
for i=1,NUM_CHAT_WINDOWS do
|
||||
local frame = _G["ChatFrame"..i]
|
||||
if frame and not frame.ShaguTweaksExtrasTimestampAddMessage then
|
||||
frame.ShaguTweaksExtrasTimestampAddMessage = frame.AddMessage
|
||||
frame.AddMessage = function(self, msg, a1, a2, a3, a4, a5)
|
||||
if not msg then return end
|
||||
local function InstallTimestampHooks()
|
||||
for i = 1, NUM_CHAT_WINDOWS do
|
||||
local frame = _G["ChatFrame"..i]
|
||||
if frame and not frame.ShaguTweaksExtrasTimestampAddMessage then
|
||||
frame.ShaguTweaksExtrasTimestampAddMessage = frame.AddMessage
|
||||
frame.AddMessage = function(self, msg, a1, a2, a3, a4, a5)
|
||||
if not msg then return end
|
||||
|
||||
msg = color .. left .. date(format) .. right .. "|r " .. msg
|
||||
self:ShaguTweaksExtrasTimestampAddMessage(msg, a1, a2, a3, a4, a5)
|
||||
msg = color .. left .. date(format) .. right .. "|r " .. msg
|
||||
self:ShaguTweaksExtrasTimestampAddMessage(msg, a1, a2, a3, a4, a5)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Install after the normal ShaguTweaks module pass. Chat Tweaks in the
|
||||
-- main fork also wraps AddMessage, and its module order is intentionally
|
||||
-- unordered. Waiting for PLAYER_ENTERING_WORLD makes timestamps the outer
|
||||
-- wrapper every time, so history consistently stores the displayed time.
|
||||
local installer = CreateFrame("Frame", nil, UIParent)
|
||||
installer:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
installer:SetScript("OnEvent", function()
|
||||
InstallTimestampHooks()
|
||||
this:UnregisterAllEvents()
|
||||
this:Hide()
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user