• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Unread count fails for >999 items

Affected version
XF Beta 1

Kier

XenForo Developer
Staff member
#2
Hmm... well it's not a limit in the CSS or styling, as the inspector allows this

1505217128630.png

... so it must be something on the PHP side
 

Xon

Well-known member
#3
@Kier it appears to be a javascript/php localization issue.

In updateVisitorCounts, visitor.alerts_unread has the literal string; "1,000"

When calling XF.badgeCounterUpdate, there is the following code:
Code:
            if (newCount > 0)
            {
                $badge.addClass('badgeContainer--highlighted');
            }
            else
            {
                $badge.removeClass('badgeContainer--highlighted');
            }
"1,000" > 0 fails, so it removes the highlight class.


Looking at where visitorCount is initialized in the page:

1505218186729.png
 
Last edited:

Xon

Well-known member
#4
In the template; helper_js_global

Code:
visitorCounts: {
   conversations_unread: '{$xf.visitor.conversations_unread|number}',
   alerts_unread: '{$xf.visitor.alerts_unread|number}',
   total_unread: '{{ ($xf.visitor.conversations_unread + $xf.visitor.alerts_unread)|number }}',
Piping to |number is going to hit localization issues on the JavaScript side likely having different formatting rules to the server.