Skip to content

Commit

Permalink
Don't try to meddle with MiniMapMailFrame if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kemayo committed Nov 20, 2022
1 parent fe4be23 commit c6b3075
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions OpenAll.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,24 @@ function copper_to_pretty_money(c)
end
end

mail_checker = CreateFrame("Frame")
mail_checker:Hide()
mail_checker:SetScript("OnShow", function(this)
this:RegisterEvent("MAIL_INBOX_UPDATE")
CheckInbox()
end)
mail_checker:SetScript("OnHide", function(this)
if select(2, GetInboxNumItems()) > 0 then
MiniMapMailFrame:Show()
else
MiniMapMailFrame:Hide()
end
end)
mail_checker:SetScript("OnEvent", function(this, event, ...)
if event == "MAIL_INBOX_UPDATE" then
this:Hide()
this:UnregisterEvent("MAIL_INBOX_UPDATE")
end
end)
if _G.MiniMapMailFrame then
mail_checker = CreateFrame("Frame")
mail_checker:Hide()
mail_checker:SetScript("OnShow", function(this)
this:RegisterEvent("MAIL_INBOX_UPDATE")
CheckInbox()
end)
mail_checker:SetScript("OnHide", function(this)
if select(2, GetInboxNumItems()) > 0 then
MiniMapMailFrame:Show()
else
MiniMapMailFrame:Hide()
end
end)
mail_checker:SetScript("OnEvent", function(this, event, ...)
if event == "MAIL_INBOX_UPDATE" then
this:Hide()
this:UnregisterEvent("MAIL_INBOX_UPDATE")
end
end)
end

0 comments on commit c6b3075

Please sign in to comment.