From 003915bbcb27e1cf8e0893ae6d5d816bac0a634a Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Tue, 1 Sep 2026 14:26:56 +0200 Subject: [PATCH] Run player cleanup after realm entry --- mods/social-colors.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/social-colors.lua b/mods/social-colors.lua index f3a5398..15f4213 100644 --- a/mods/social-colors.lua +++ b/mods/social-colors.lua @@ -175,16 +175,21 @@ end HookChatColors() module.enable = function(self) - local playerdb, realmdb = GetPlayerCache() - CleanupPlayerDB(playerdb, realmdb) - -- Defensive second call for chat frames created/replaced by another addon -- between file load and VARIABLES_LOADED. Existing hooks are never duplicated. HookChatColors() local socialmod = CreateFrame("Frame", "ShaguTweaksSocialMod", UIParent) + socialmod:RegisterEvent("PLAYER_ENTERING_WORLD") socialmod:RegisterEvent("CHAT_MSG_SYSTEM") socialmod:SetScript("OnEvent", function() + if event == "PLAYER_ENTERING_WORLD" then + local playerdb, realmdb = GetPlayerCache() + CleanupPlayerDB(playerdb, realmdb) + this:UnregisterEvent("PLAYER_ENTERING_WORLD") + return + end + local currentdb = GetPlayerCache() local name = cmatch(arg1, _G.ERR_FRIEND_ONLINE_SS) or cmatch(arg1, _G.ERR_FRIEND_OFFLINE_S) if name and currentdb[name] then