ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   SortFilterList/Notification MotD bug (https://www.esoui.com/forums/showthread.php?t=5269)

circonian 11/07/15 06:04 PM

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

ZOS_ChipHilseberg 11/09/15 04:41 PM

Thanks, circonian.

sirinsidiator 11/09/15 06:51 PM

I also found two minor bugs in SortFilterList.
UPDATE_VISIBLE used in line 165 is not defined and SetEmptyText does not check if emptyRow already exists which causes an error if it gets called more than once.


All times are GMT -6. The time now is 08:15 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI