I am currently playing around with the notification system and have encountered some strangeness that I cannot explain to myself.
My test setup:
Lua Code:
ZO_PreHook(CHAT_SYSTEM, "OnNumNotificationsChanged", function(self, totalNumNotifications)
d("changed from " .. tostring(self.currentNumNotifications) .. " to " .. totalNumNotifications)
if(totalNumNotifications > 0) then error("test") end
end)
zo_callLater(function()
d(NOTIFICATIONS.eventNamespace)
d(EVENT_MANAGER:UnregisterForEvent(NOTIFICATIONS.eventNamespace, EVENT_RAID_SCORE_NOTIFICATION_ADDED))
d(EVENT_MANAGER:UnregisterForEvent(NOTIFICATIONS.eventNamespace, EVENT_RAID_SCORE_NOTIFICATION_REMOVED))
EVENT_MANAGER:RegisterForEvent("test", EVENT_RAID_SCORE_NOTIFICATION_ADDED, function() d("add event") end)
EVENT_MANAGER:RegisterForEvent("test", EVENT_RAID_SCORE_NOTIFICATION_REMOVED, function() d("remove event") end)
end, 1000)
I expect this to hide the raid notifications until some other event refreshes the notification manager.
When I load the addon I get:
Code:
KeyboardNotifications
true
true
Which means it has unregistered both events successfully, but instead of ignoring the raid notifications it still handles them as if I never unregistered the event.
When I already have got some of them in my notifications panel and press the delete button, it shows
Code:
remove event
changed from 4 to 3
and then throws my error with the following stack traceback:
Code:
[C]: in function 'error'
user:/AddOns/test/test.lua:42: in function 'hookFunction'
EsoUI/Libraries/Utility/ZO_Hook.lua:19: in function 'OnNumNotificationsChanged'
EsoUI/Ingame/Contacts/Notifications_Common.lua:705: in function 'ZO_NotificationManager:BuildNotificationList'
EsoUI/Ingame/Contacts/Notifications_Common.lua:678: in function 'ZO_NotificationManager:RefreshNotificationList'
EsoUI/Ingame/Contacts/Notifications_Common.lua:58: in function 'ZO_NotificationProvider:PushUpdateToNotificationManager'
EsoUI/Ingame/Contacts/Notifications_Common.lua:34: in function '(anonymous)'
When I let myself get killed and revive, it also throws the same error two times in a row.
Notifications_Common.lua:34 is inside the handler function that gets registered to both events in question and is - as far as I can see - never used anywhere else.
Maybe somebody can explain to me what is happening.