View Single Post
04/25/14, 04:58 PM   #3
Teli
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 19
Originally Posted by Seerah View Post
The best way is to listen for the appropriate events.
I'm doing that with an event handler but the problem is how do I get the delete another item only after the even has fired. there is a delay in when I call the event. So if I have
Lua Code:
  1. for k1, v1 in pairs(mailInfo) do
  2.   d(delComplete)
  3.    if delComplete then DeleteMail(v1.mailId,false) end
  4.    delComplete = false --mark it as false only the event can mark it as true
  5. end
and an event handler
Lua Code:
  1. delComplete = true
  2. function mailOpen.MailRemoved(eventCode, mailId)
  3.    delComplete = true -- mark it true from event code
  4.    d('mail removed')
  5. end

It'll delete the first item and it won't delete the rest. I tried it like this. and get the same thing.

Lua Code:
  1. for k1, v1 in pairs(mailInfo) do
  2.    DeleteMail(v1.mailId,false)
  3. end

The chat window displays

Code:
true
false
false
false
false
false
mail removed
So the problem seems to be it runs through all the addon code first
  Reply With Quote