local C = Broker_Everything.color

local mail_init = function()
	MiniMapMailFrame:Hide()
	MiniMapMailFrame.Show = dummyFunc
end

		
local mail_onevent = function(self)
	local dataobj = self.obj  or LibStub:GetLibrary("LibDataBroker-1.1"):GetDataObjectByName(L["MAIL"])

	if HasNewMail() then
		dataobj.text = C.dkgreen(L["NEWMAIL"])
		dataobj.icon = "Interface\\Addons\\Broker_Everything\\media\\mail_new"
	else
		dataobj.text = L["No Mail"]
		dataobj.icon = "Interface\\Addons\\Broker_Everything\\media\\mail_none"
	end
end


local mail_events = {
	"UPDATE_PENDING_MAIL",
	"MAIL_INBOX_UPDATE",
	"MAIL_CLOSED",
	"PLAYER_LOGIN",
	"PLAYER_ENTERING_WORLD"
}


local mail_tooltip = function(t)
	local a, b, c = GetLatestThreeSenders()
	t:AddLine(L["MAIL"])

	t:AddLine(" ")
	if not a then
		t:AddLine(L["No Mail"])
		return
	end

	t:AddLine(L["Mail From"])
	t:AddLine(a)

	if b then t:AddLine (b) end
	if c then t:AddLine (c) end
end


Broker_Everything:Register(L["MAIL"],
	--GetItemIcon (9555),
	--"Interface\\Minimap\\TRACKING\\Mailbox",
	"Interface\\Addons\\Broker_Everything\\media\\mail_none",
	mail_init,
	mail_onevent,
	mail_events,
	0,
	mail_tooltip,
	nil,
	nil)
