fix: mailbox performance
This commit is contained in:
+23
-32
@@ -270,44 +270,35 @@ function MailboxScanner:Initialize()
|
|||||||
return originalPlaceAuctionBid(type, index, bid)
|
return originalPlaceAuctionBid(type, index, bid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Hook taking items/money to update database immediately
|
||||||
|
local originalTakeInboxItem = TakeInboxItem
|
||||||
|
TakeInboxItem = function(index, attachmentIndex)
|
||||||
|
local result = originalTakeInboxItem(index, attachmentIndex)
|
||||||
|
MailboxScanner:SaveToDatabase()
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local originalTakeInboxMoney = TakeInboxMoney
|
||||||
|
TakeInboxMoney = function(index)
|
||||||
|
local result = originalTakeInboxMoney(index)
|
||||||
|
MailboxScanner:SaveToDatabase()
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local originalAutoLootMailItem = AutoLootMailItem
|
||||||
|
AutoLootMailItem = function(index)
|
||||||
|
local result = originalAutoLootMailItem(index)
|
||||||
|
MailboxScanner:SaveToDatabase()
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
-- Mailbox opened
|
-- Mailbox opened
|
||||||
addon.Modules.Events:OnMailShow(function()
|
addon.Modules.Events:OnMailShow(function()
|
||||||
mailboxOpen = true
|
mailboxOpen = true
|
||||||
addon:Debug("Mailbox opened")
|
addon:Debug("Mailbox opened")
|
||||||
|
MailboxScanner:SaveToDatabase()
|
||||||
-- Delay scan slightly to ensure item info is available
|
|
||||||
local frame = CreateFrame("Frame")
|
|
||||||
local elapsed = 0
|
|
||||||
frame:SetScript("OnUpdate", function()
|
|
||||||
elapsed = elapsed + arg1
|
|
||||||
if elapsed >= 0.5 then
|
|
||||||
frame:SetScript("OnUpdate", nil)
|
|
||||||
if mailboxOpen then
|
|
||||||
MailboxScanner:SaveToDatabase()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end, "MailboxScanner")
|
end, "MailboxScanner")
|
||||||
|
|
||||||
-- Register for GET_ITEM_INFO_RECEIVED to refresh if item data arrives
|
|
||||||
addon.Modules.Events:Register("GET_ITEM_INFO_RECEIVED", function()
|
|
||||||
if mailboxOpen then
|
|
||||||
addon:Debug("GET_ITEM_INFO_RECEIVED: Refreshing mailbox")
|
|
||||||
MailboxScanner:SaveToDatabase()
|
|
||||||
end
|
|
||||||
end, "MailboxScanner")
|
|
||||||
|
|
||||||
-- Register for MAIL_INBOX_UPDATE to detect when mail content changes
|
|
||||||
addon.Modules.Events:Register("MAIL_INBOX_UPDATE", function()
|
|
||||||
if mailboxOpen then
|
|
||||||
addon:Debug("MAIL_INBOX_UPDATE: Refreshing mailbox")
|
|
||||||
MailboxScanner:SaveToDatabase()
|
|
||||||
end
|
|
||||||
end, "MailboxScanner")
|
|
||||||
|
|
||||||
-- Register for UI_ERROR_MESSAGE to handle "item not found" situations if needed
|
|
||||||
-- (Some items might not be in cache and fail silently otherwise)
|
|
||||||
|
|
||||||
-- Mailbox closed
|
-- Mailbox closed
|
||||||
addon.Modules.Events:OnMailClosed(function()
|
addon.Modules.Events:OnMailClosed(function()
|
||||||
-- Final save on close
|
-- Final save on close
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
## Title: Guda
|
## Title: Guda
|
||||||
## Notes: All-in-one bag and bank addon for Turtle WoW
|
## Notes: All-in-one bag and bank addon for Turtle WoW
|
||||||
## Author: Vati
|
## Author: Vati
|
||||||
## Version: 1.5.0
|
## Version: 1.5.1
|
||||||
## SavedVariables: Guda_DB
|
## SavedVariables: Guda_DB
|
||||||
## SavedVariablesPerCharacter: Guda_CharDB
|
## SavedVariablesPerCharacter: Guda_CharDB
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user