Fix missing Open Mail button and bump to 1.4.9

- Recreate the Open Mail button if it is missing
- Restore its parent, position, text and click handler
- Ensure the button stays visible above the inbox UI
- Reapply the fix when the mailbox opens or updates
- Bump version to 1.4.9
This commit is contained in:
2026-09-14 07:17:16 +00:00
parent 0853d3854c
commit 6aab69a116
4 changed files with 77 additions and 6 deletions
+67 -1
View File
@@ -8,7 +8,7 @@ local m = TurtleMail
local getn = table.getn
local function pack( ... ) return arg end
m.compat_version = "1.4.8"
m.compat_version = "1.4.9"
local DEFAULT_SENT_FILTERS = {
Money = 1,
@@ -179,6 +179,69 @@ local function restore_real_mail_widgets_for_upstream()
if edit_box then m.api.SendMailSubjectEditBox = edit_box end
end
-- The upstream Open Mail button is created only once in inbox_load(). If that
-- creation is skipped/interrupted, or another UI addon hides/re-parents the
-- button afterwards, TurtleMail never recreates it. Keep the button recoverable
-- whenever the mailbox/inbox is shown or refreshed.
local function ensure_open_mail_button()
local inbox = m.api.InboxFrame
if not inbox or not m.api.CreateFrame then return nil end
local button = m.api.TurtleMailOpenMailButton
if not button or type( button.SetPoint ) ~= "function" then
button = m.api.CreateFrame( "Button", "TurtleMailOpenMailButton", inbox, "UIPanelButtonTemplate" )
m.api.TurtleMailOpenMailButton = button
end
if button.SetParent then button:SetParent( inbox ) end
if button.ClearAllPoints then button:ClearAllPoints() end
button:SetPoint( "BOTTOM", inbox, "BOTTOM", -10, 90 )
if button.SetText then button:SetText( m.api.OPENMAIL or "Open Mail" ) end
local width = 120
local font_string = button.GetFontString and button:GetFontString()
if font_string and font_string.GetStringWidth then
width = math.max( 120, 30 + (font_string:GetStringWidth() or 0) )
end
if button.SetWidth then button:SetWidth( width ) end
if button.SetHeight then button:SetHeight( 25 ) end
if button.SetScript then button:SetScript( "OnClick", m.inbox_open_all ) end
if inbox.GetFrameLevel and button.SetFrameLevel then
button:SetFrameLevel( (inbox:GetFrameLevel() or 0) + 5 )
end
if button.Enable then button:Enable() end
if button.Show then button:Show() end
return button
end
-- Replace the fragile one-shot inbox loader with an idempotent version. This
-- preserves upstream behavior while making Open Mail recoverable instead of
-- relying on the initial CreateFrame call succeeding forever.
function m.inbox_load()
if m.api.InboxFrame and m.api.InboxFrame.EnableMouse then
m.api.InboxFrame:EnableMouse( false )
end
ensure_open_mail_button()
for i = 1, 7 do
local auction_texture = m.api[ "TurtleMailAuctionIcon" .. i .. "Texture" ]
local returned_texture = m.api[ "TurtleMailReturnedArrow" .. i .. "Texture" ]
local color = m.api.NORMAL_FONT_COLOR
if color and auction_texture and auction_texture.SetVertexColor then
auction_texture:SetVertexColor( color.r, color.g, color.b )
end
if color and returned_texture and returned_texture.SetVertexColor then
returned_texture:SetVertexColor( color.r, color.g, color.b )
end
end
end
-- SavedVariables are not guaranteed to have a valid schema. Repair them before
-- the original handlers touch nested fields.
do
@@ -364,6 +427,7 @@ function m.MAIL_SHOW()
-- recovers if another UI addon changed those globals after addon loading.
ensure_send_mail_button()
ensure_subject_edit_box()
ensure_open_mail_button()
if not m.api.MailFrame then return end
@@ -466,6 +530,8 @@ end
-- Hide stale AH/returned icons on rows that no longer contain mail.
function m.MAIL_INBOX_UPDATE()
ensure_open_mail_button()
if m.inbox_opening then
m.inbox_update = true
end