added "Func Call Spam Protection" for "CURRENCY_DISPLAY_UPDATE" Event in "DataStore_Currencies" file
This commit is contained in:
@@ -6,12 +6,15 @@ if not DataStore then return end
|
|||||||
|
|
||||||
local addonName = "DataStore_Currencies"
|
local addonName = "DataStore_Currencies"
|
||||||
|
|
||||||
_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0")
|
_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0")
|
||||||
|
|
||||||
local addon = _G[addonName]
|
local addon = _G[addonName]
|
||||||
|
|
||||||
local THIS_ACCOUNT = "Default"
|
local THIS_ACCOUNT = "Default"
|
||||||
|
|
||||||
|
-- Func Call Spam Protection
|
||||||
|
local FCSP_timer_OnCurrencyDisplayUpdate
|
||||||
|
|
||||||
local AddonDB_Defaults = {
|
local AddonDB_Defaults = {
|
||||||
global = {
|
global = {
|
||||||
Characters = {
|
Characters = {
|
||||||
@@ -81,8 +84,15 @@ end
|
|||||||
|
|
||||||
-- *** Event Handlers ***
|
-- *** Event Handlers ***
|
||||||
local function OnCurrencyDisplayUpdate()
|
local function OnCurrencyDisplayUpdate()
|
||||||
|
FCSP_timer_UNIT_INVENTORY_CHANGED = nil
|
||||||
ScanCurrencies()
|
ScanCurrencies()
|
||||||
end
|
end
|
||||||
|
local function FCSP_timer_OnCurrencyDisplayUpdate()
|
||||||
|
-- this function limits calls to "ScanCurrencies" to max 1 every second
|
||||||
|
|
||||||
|
if FCSP_timer_UNIT_INVENTORY_CHANGED then return end
|
||||||
|
FCSP_timer_UNIT_INVENTORY_CHANGED = addon:ScheduleTimer(OnCurrencyDisplayUpdate, 1)
|
||||||
|
end
|
||||||
|
|
||||||
-- ** Mixins **
|
-- ** Mixins **
|
||||||
local function _GetNumCurrencies(character)
|
local function _GetNumCurrencies(character)
|
||||||
@@ -178,7 +188,8 @@ function addon:OnInitialize()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function addon:OnEnable()
|
function addon:OnEnable()
|
||||||
addon:RegisterEvent("CURRENCY_DISPLAY_UPDATE", OnCurrencyDisplayUpdate)
|
-- addon:RegisterEvent("CURRENCY_DISPLAY_UPDATE", OnCurrencyDisplayUpdate)
|
||||||
|
addon:RegisterEvent("CURRENCY_DISPLAY_UPDATE", FCSP_timer_OnCurrencyDisplayUpdate)
|
||||||
end
|
end
|
||||||
|
|
||||||
function addon:OnDisable()
|
function addon:OnDisable()
|
||||||
|
|||||||
Reference in New Issue
Block a user