fix: poor tooltip for mailboxframe
This commit is contained in:
@@ -230,6 +230,48 @@ function DB:SaveMailbox(mailboxData)
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a single mail entry to a character's mailbox
|
||||
function DB:AddMailToCharacter(name, realm, mailRow)
|
||||
local fullName = name .. "-" .. (realm or playerRealm)
|
||||
local char = Guda_DB.characters[fullName]
|
||||
|
||||
if char then
|
||||
if not char.mailbox then
|
||||
char.mailbox = {}
|
||||
end
|
||||
|
||||
-- Check if this exact mail already exists (simplistic check)
|
||||
local exists = false
|
||||
for _, m in ipairs(char.mailbox) do
|
||||
if m.sender == mailRow.sender and m.subject == mailRow.subject and m.money == mailRow.money then
|
||||
if (not m.item and not mailRow.item) or (m.item and mailRow.item and m.item.name == mailRow.item.name and m.item.count == mailRow.item.count) then
|
||||
exists = true
|
||||
-- Update link/itemID if missing in existing but present in new
|
||||
if mailRow.item and m.item then
|
||||
if not m.item.link and mailRow.item.link then
|
||||
m.item.link = mailRow.item.link
|
||||
addon:Debug("Updated link for existing mail item")
|
||||
end
|
||||
if not m.item.itemID and mailRow.item.itemID then
|
||||
m.item.itemID = mailRow.item.itemID
|
||||
addon:Debug("Updated itemID for existing mail item")
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not exists then
|
||||
table.insert(char.mailbox, 1, mailRow) -- Add to beginning
|
||||
char.lastUpdate = time()
|
||||
addon:Debug("Added outgoing mail to %s's mailbox", fullName)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Get all characters (optionally filter by faction and/or realm)
|
||||
function DB:GetAllCharacters(sameFactionOnly, currentRealmOnly)
|
||||
local chars = {}
|
||||
|
||||
+6
-6
@@ -101,10 +101,13 @@ scanTooltip:SetOwner(WorldFrame, "ANCHOR_NONE")
|
||||
|
||||
-- Get item link from mailbox attachment (WoW 1.12.1 workaround)
|
||||
function Utils:GetInboxItemLink(index, itemIndex)
|
||||
-- Try global function first (if it exists on this server/version)
|
||||
if GetInboxItemLink then
|
||||
local link = GetInboxItemLink(index)
|
||||
if link then return link end
|
||||
end
|
||||
|
||||
-- In 1.12.1, GameTooltip:GetHyperlink() does not exist.
|
||||
-- Actually, in 1.12.1, there's no official API to get the link from a mailbox item
|
||||
-- if GetInboxItemLink(index) is not available (it's often NOT available in Vanilla).
|
||||
|
||||
-- Let's try to use GetItemInfo(name) as the primary way.
|
||||
local name = GetInboxItem(index, itemIndex)
|
||||
if name then
|
||||
@@ -114,9 +117,6 @@ function Utils:GetInboxItemLink(index, itemIndex)
|
||||
end
|
||||
end
|
||||
|
||||
-- Fallback: If we still don't have it, we might try to scan the tooltip for the name
|
||||
-- but GetInboxItem already gave us the name.
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user