From eed35fd37d274eb30914a2a7d45955c38b90c8f1 Mon Sep 17 00:00:00 2001 From: urnati Date: Tue, 5 May 2026 13:02:42 -0400 Subject: [PATCH] - "time played" spam fixed (again)... --- Titan/TitanUtils.lua | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index 506c84e..f62653a 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -1897,25 +1897,46 @@ function TitanUtils_DecompressData(data, dataType) end --====== Overload the 'time played' text to Chat to not show 'time played' to Chat -local requesting = 0 +local orig_ChatFrame_DisplayTimePlayed = function(...) end -- place holder --- Save orignal output to Chat -local orig_ChatFrame_DisplayTimePlayed = function(...) end +local requesting = 0 +local function ChatPlayedHelper(...) + -- A little clunky but calls done rapidly should sort themselves + -- even if the exact call to event does not match. + if requesting > 0 then + -- Titan requested time played, do not spam Chat + requesting = requesting - 1 + else + -- Did not request time played so output + ---@diagnostic disable-next-line: need-check-nil + orig_ChatFrame_DisplayTimePlayed(...) + end +end +if ChatFrameUtil.DisplayTimePlayed then + -- Newer API + -- Check new first; Old routine exists (deprecated) in new... orig_ChatFrame_DisplayTimePlayed = ChatFrameUtil.DisplayTimePlayed - ChatFrameUtil.DisplayTimePlayed = function(...) --TimePlayed(...) - -- A little clunky but calls done rapidly should sort themselves - -- even if the exact call to event does not match. - if requesting > 0 then - -- Titan requested time played, do not spam Chat - requesting = requesting - 1 - else - -- Did not request time played so output - ---@diagnostic disable-next-line: need-check-nil - orig_ChatFrame_DisplayTimePlayed(...) + ChatFrameUtil.DisplayTimePlayed = function(...) + ChatPlayedHelper(...) end - end +else + -- Old Classic + orig_ChatFrame_DisplayTimePlayed = ChatFrame_DisplayTimePlayed + + ChatFrame_DisplayTimePlayed = function(...) + ChatPlayedHelper(...) + end +end + +---Titan Get time played in a general way to not spam Chat +---@param reason string For debug +function TitanUtils_GetTimePlayed(reason) + requesting = requesting + 1 + + RequestTimePlayed() +end ---Titan Get time played in a general way to not spam Chat ---@param reason string For debug -- 1.7.9.5