Thread Tools Display Modes
Prev Previous Post   Next Post Next
11/07/15, 06:04 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
SortFilterList/Notification MotD bug

There is a bug in the notification system involving MoTD notifications. The MotDProvider:BuildNotificationList() function creates message tables that do not contain a secsSinceRequest key, which is the key that is used to sort the SortFilterList notifications:
Lua Code:
  1. function ZO_GuildMotDProvider:BuildNotificationList()
  2.    ...
  3.                 table.insert(self.list,
  4.                 {
  5.                     dataType = NOTIFICATIONS_ALERT_DATA,
  6.                     notificationType = NOTIFICATION_TYPE_GUILD_MOTD,
  7.                     --=====================================================--
  8.                     --== It should have this key, but it doesn't ==========--
  9.                     --=====================================================--
  10.                     --secsSinceRequest  = ZO_NormalizeSecondsSince(0),
  11.                     --=====================================================--
  12.                     note = currentMotD,
  13.                     message = message,
  14.                     guildId = guildId,
  15.                     shortDisplayText = guildName,                })          
  16.             end
  17.         end
  18.     end
  19. end

Its the key used to sort the notification list:
Lua Code:
  1. function ZO_NotificationList:CompareNotifications(listEntry1, listEntry2)
  2.     return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, "secsSinceRequest", ENTRY_SORT_KEYS, ZO_SORT_ORDER_DOWN)
  3. end

While we are at it the table ordering function that gets called during the sort process should probably be updated to handle such mistakes (it does not handle entries well when the sortKey does not exist). It could use some kind of check to ensure that the value1 & value2 are not nil & if so handle them properly.
Lua Code:
  1. function ZO_TableOrderingFunction(entry1, entry2, sortKey, sortKeys, sortOrder)
  2.    -- If either of these values turn out nil because the sortKey does not exist
  3.    -- it messes up the entire sort.
  4.     local value1 = entry1[sortKey]
  5.     local value2 = entry2[sortKey]
  6.    
  7.     local value1Type = type(value1)
  8.     local value2Type = type(value2)
  9.    
  10.     -- Add a check to see if value2Type is nil
  11.     -- If value2Type and value1Type are both nil, use the tiebreaker
  12.     -- if only value2Type is nil, return true
  13.     if value2Type == "nil" then
  14.         if value1Type == value2Type then
  15.             local tiebreaker = sortKeys[sortKey].tiebreaker
  16.             return ZO_TableOrderingFunction(entry1, entry2, tiebreaker, sortKeys, nextSortOrder)
  17.         end
  18.         return true
  19.     end
  20.    
  21.     -- if value2Type is not nil, but value1Type is, this check will handle that case:
  22.     if value1Type ~= value2Type or not validOrderingTypes[value1Type] then
  23.         return false
  24.     end
  25.   ...
  26. end

Last edited by circonian : 11/08/15 at 12:27 AM.
  Reply With Quote
 

ESOUI » Developer Discussions » General Authoring Discussion » SortFilterList/Notification MotD bug

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off