local addonName, TOAST = ...

local icon = LibStub("LibDBIcon-1.0")
local ldb  = LibStub("LibDataBroker-1.1")

local dataobj = ldb:NewDataObject("TOAST", {
    type = "launcher",
    icon = "Interface\\AddOns\\TOAST\\media\\TOAST",
    OnClick = function(_, button)
        if button == "LeftButton" then
            TOAST.commands[""]()
        elseif button == "RightButton" then
            TOAST.commands["lb"]()
        end
    end,
    OnTooltipShow = function(tooltip)
        tooltip:AddLine("|cff33ff99TOAST|r")
        tooltip:AddLine("Left: Dashboard", 1, 1, 1)
        tooltip:AddLine("Right: Leaderboard", 1, 1, 1)
    end,
})

local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(self, event, name)
    if name ~= addonName then return end
    self:UnregisterEvent(event)
    TOAST_DB.minimap = TOAST_DB.minimap or {}
    icon:Register("TOAST", dataobj, TOAST_DB.minimap)
end)
