Favorite Contacts

Favorite Contacts

25.4k Downloads

[Retail] Fix for "Send mail with click on contact" feature

tflo opened this issue ยท 8 comments

commented

For me and with WoW Retail, the "Send mail with click on contact" doesn't work, i.e. it needs 2 clicks instead of one. This was already the case with the previous version of FC.

Postponing MailFrameTab_OnClick fixes it for me with the latest version (2.9):

diff --git a/FavoriteContacts/UI/MailModule.lua b/FavoriteContacts/UI/MailModule.lua
--- a/FavoriteContacts/UI/MailModule.lua
+++ b/FavoriteContacts/UI/MailModule.lua
@@ -28,12 +28,12 @@
             container.ContactHandler = function(_, contact)
-                MailFrameTab_OnClick(nil, 2)
                 SendMailNameEditBox:SetText(contact.recipient)
+                MailFrameTab_OnClick(nil, 2)
                 SendMailSubjectEditBox:SetFocus()

                 if CursorHasItem() then
                     SendMailAttachmentButton_OnDropAny()
                 end
                 if ADDON.settings.clickToSend then
                     SendMail()
                 end
             end

I have not tested if this has any negative side effects on Wrath or Classic.

An alternative solution that worked for me with FC 2.8 (not tested with 2.9) was to simply call the SendMail function with a 1-frame delay:

if ADDON.settings.clickToSend then
    C_Timer.After(0, SendMail)
end

Edit/PS:

This is in conjunction with the original Blizz mail interface. Interestingly, last time I tried with EasyMail (and if memory serves also with Postal), the 1-click sending worked without any modification on FC's side.

commented

Since my last post above, I have been using the second fix (C_Timer) all the time, and as suspected, it is more reliable than reordering the function calls. More specifically, I haven't had a single 1-click failure so far (as opposed to the occasional failures with fix #โ 1 before).

So if you are going to use one of these, I recommend the C_Timer one.

commented

I was able to replicate that bug once also using EasyMail and Postal. Still couldn't figure out why that happens.
Maybe something with load order. There are a lot of hooks in all addons :|

commented

There are a lot of hooks in all addons

My suggestion fixes the 1-click send behavior in conjunction with Blizz's mail interface, because your 1-click-send never worked for me there.

I mentioned EasyMail and Postal only because I found it noteworthy that the 1-click-send works there (or most of the times works there) also without my fix.

In the meantime I noticed that sometimes the 1-click-send fails even with my fix. But this is like 1 out of 15 times or so, hence probably negligible. But maybe the alternative approach (with the 1-frame C_Timer) is a lil' bit more reliable, I have not tested it yet with the current version. โ€“ Combining both would also be a possibility.

commented

I think I found the problem. Adding an item as attachment doesn't always updates the MailFrame right away. Instead a MAIL_SEND_INFO_UPDATE event gets triggered on which the MailFrame updates itself. During that update the subject also gets set, which is a condition for the SendMailMailButton to get activated.
Soo.. if MAIL_SEND_INFO_UPDATE gets delayed even by a single frame the existing code does indeed not work.

Thank you for reporting this bug ๐Ÿ˜ƒ

commented

(Hopefully) fixed in version 2.9.1 :)

commented

Unfortunately not (for me), 2.9.1 still requires 2 clicks. After the first click the cursor moves from the Recipient field to the end of the Subject field and stays there, 2nd click sends it; so basically like before.

If the recipient is pre-filled, 1 click is enough to send. But this is also 2 clicks in total (1st to fill the recipient in, 2nd to send).

Good thing is that each of the modifications from my OP still works. (Also tested the C_Timer version this time.)

Updated diffs:

Calling MailFrameTab_OnClick after SetText
diff --git a/FavoriteContacts/UI/MailModule.lua b/FavoriteContacts/UI/MailModule.lua
--- a/FavoriteContacts/UI/MailModule.lua
+++ b/FavoriteContacts/UI/MailModule.lua
@@ -26,12 +26,12 @@
 local function ContactHandler(_, contact)
-    MailFrameTab_OnClick(nil, 2)
     SendMailNameEditBox:SetText(contact.recipient)
+    MailFrameTab_OnClick(nil, 2)
     SendMailSubjectEditBox:SetFocus()
 
     if CursorHasItem() then
         OnNextInfoUpdate = ClickToSend
         SendMailAttachmentButton_OnDropAny() -- triggers event: MAIL_SEND_INFO_UPDATE
     else
         ClickToSend()
     end
 end
With C_Timer for ClickToSend
diff --git a/FavoriteContacts/UI/MailModule.lua b/FavoriteContacts/UI/MailModule.lua
--- a/FavoriteContacts/UI/MailModule.lua
+++ b/FavoriteContacts/UI/MailModule.lua
@@ -26,12 +26,12 @@
 local function ContactHandler(_, contact)
     MailFrameTab_OnClick(nil, 2)
     SendMailNameEditBox:SetText(contact.recipient)
     SendMailSubjectEditBox:SetFocus()
 
     if CursorHasItem() then
         OnNextInfoUpdate = ClickToSend
         SendMailAttachmentButton_OnDropAny() -- triggers event: MAIL_SEND_INFO_UPDATE
     else
-        ClickToSend()
+        C_Timer.After(0, ClickToSend)
     end
 end
commented

I'm using a little delay as well. I hope that helps in your case.

fixed (again) in version 2.11

commented

Some time ago I installed an FC update and did not immediately apply my local patches, to see if you had fixed the problem in the meantime. And the single click worked.

My plan was to investigate whether this was due to a fix from you, or some unknown change in my local environment, and report back after some more extensive testing, but yeah, I completely forgot about both ๐Ÿ™„. Sorry for that.