From ae8e94a8110c03883be0105a9377498d146e07d8 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 9 Jun 2019 22:05:10 +0200 Subject: [PATCH] updatenotify: cache tables and notify group members --- modules/updatenotify.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/updatenotify.lua b/modules/updatenotify.lua index 5d1b5949..14038f49 100644 --- a/modules/updatenotify.lua +++ b/modules/updatenotify.lua @@ -2,10 +2,13 @@ pfUI:RegisterModule("updatenotify", 20400, function () local alreadyshown = false local localversion = tonumber(pfUI.version.major*10000 + pfUI.version.minor*100 + pfUI.version.fix) local remoteversion = tonumber(pfUI_init.updateavailable) or 0 + local loginchannels = { "BATTLEGROUND", "RAID", "GUILD" } + local groupchannels = { "BATTLEGROUND", "RAID" } pfUI.updater = CreateFrame("Frame") pfUI.updater:RegisterEvent("CHAT_MSG_ADDON") pfUI.updater:RegisterEvent("PLAYER_ENTERING_WORLD") + pfUI.updater:RegisterEvent("PARTY_MEMBERS_CHANGED") pfUI.updater:SetScript("OnEvent", function() if event == "CHAT_MSG_ADDON" and arg1 == "pfUI" then local v, remoteversion = pfUI.api.strsplit(":", arg2) @@ -17,6 +20,16 @@ pfUI:RegisterModule("updatenotify", 20400, function () end end + if event == "PARTY_MEMBERS_CHANGED" then + local groupsize = GetNumRaidMembers() > 0 and GetNumRaidMembers() or GetNumPartyMembers() > 0 and GetNumPartyMembers() or 0 + if ( this.group or 0 ) < groupsize then + for _, chan in pairs(groupchannels) do + SendAddonMessage("pfUI", "VERSION:" .. localversion, chan) + end + end + this.group = groupsize + end + if event == "PLAYER_ENTERING_WORLD" then if not alreadyshown and localversion < remoteversion then DEFAULT_CHAT_FRAME:AddMessage(T["|cff33ffccpf|rUI: New version available! Have a look at http://shagu.org !"]) @@ -25,7 +38,7 @@ pfUI:RegisterModule("updatenotify", 20400, function () alreadyshown = true end - for _, chan in pairs({ "BATTLEGROUND", "RAID", "GUILD" }) do + for _, chan in pairs(loginchannels) do SendAddonMessage("pfUI", "VERSION:" .. localversion, chan) end end