From b250f0e65377b1ffc5a3dc8459eb01dda825024d Mon Sep 17 00:00:00 2001 From: Relationship <139162359+Relationship-OctoWoW@users.noreply.github.com> Date: Tue, 14 Jul 2026 14:12:09 +0100 Subject: [PATCH] Add files via upload --- RelationshipsQuestAndItemBrowser.lua | 57 +++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/RelationshipsQuestAndItemBrowser.lua b/RelationshipsQuestAndItemBrowser.lua index 5828378..090aea1 100644 --- a/RelationshipsQuestAndItemBrowser.lua +++ b/RelationshipsQuestAndItemBrowser.lua @@ -2498,8 +2498,14 @@ end -- * the addon just finished loading (initial pass over existing chat). -- -- Scans are rate-limited to at most one every RQL_SCAN_MIN_INTERVAL. -local RQL_SCAN_MIN_INTERVAL = 0.25 -- hard cap: no more than 4 scans/sec -local RQL_SCAN_DELAY = 0.05 -- delay after event so regions are laid out +-- Near-instant update: [+] icons must track new chat lines the same frame +-- they render. A 0.25s throttle was visibly slow when messages scrolled up +-- and the old [+] drifted with them. We now scan on the very next frame. +-- Tiny throttle: enough to coalesce bursts of chat events (raids, spammy +-- channels) into a single rescan per frame-ish window, but small enough +-- that the [+] still tracks new lines effectively instantly to the eye. +local RQL_SCAN_MIN_INTERVAL = 0.03 +local RQL_SCAN_DELAY = 0.01 local RQL_SCAN_PENDING_AT = nil local RQL_SCAN_LAST_AT = 0 @@ -2553,6 +2559,19 @@ RQL_ChatWatch:SetScript("OnEvent", function() RQL_SchedulePlusScan() end) +-- Immediately hide every [+] button in the pool. Used on tab-switch so a +-- stale icon from the previous tab disappears the instant the user clicks +-- a new tab, without waiting for the next scan tick. +local function RQL_HideAllPlusButtons() + local i = 1 + while RQL_PLUS_POOL[i] do + RQL_PLUS_POOL[i]:Hide() + RQL_PLUS_POOL[i].rqlEntry = nil + i = i + 1 + end + RQL_PoolIndex = 0 +end + local function RQL_HookChatLinks() -- Chat scrolling / paging moves existing linked lines but doesn't fire -- an event. Wrap the standard scroll helpers so [+] follows the text. @@ -2576,6 +2595,40 @@ local function RQL_HookChatLinks() end end end + + -- Hook chat tab clicks so switching tabs instantly clears any stale [+] + -- from the previously-visible tab and re-scans the newly-visible one. + -- Also hook OnShow/OnHide on the frames themselves as a safety net for + -- undock/dock and other visibility changes. + for i = 1, maxFrames do + local tab = getglobal("ChatFrame" .. i .. "Tab") + if tab and not tab._rql_hooked_click then + local origClick = tab:GetScript("OnClick") + tab._rql_hooked_click = true + tab:SetScript("OnClick", function() + if origClick then origClick() end + RQL_HideAllPlusButtons() + RQL_SchedulePlusScan(0) + end) + end + local f = getglobal("ChatFrame" .. i) + if f and not f._rql_hooked_vis then + f._rql_hooked_vis = true + local origShow = f:GetScript("OnShow") + f:SetScript("OnShow", function() + if origShow then origShow() end + RQL_HideAllPlusButtons() + RQL_SchedulePlusScan(0) + end) + local origHide = f:GetScript("OnHide") + f:SetScript("OnHide", function() + if origHide then origHide() end + RQL_HideAllPlusButtons() + RQL_SchedulePlusScan(0) + end) + end + end + -- Do one pass shortly after login so already-visible chat gets [+]. RQL_SchedulePlusScan(0.3) end