From c392a77b46958555bc16592fe4d57e9ab0b7e126 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 15 Nov 2022 21:22:10 +0000 Subject: performance: just count the first 99 unseen items and display 99+ if there are more than 99 --- view/tpl/notifications_widget.tpl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'view/tpl') diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index 82b3665c3..7a4e909c7 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -306,12 +306,18 @@ if(typeof obj[type] === typeof undefined) return true; + var count = Number(obj[type].count); + + if(obj[type].count) { $('.' + type + '-button').fadeIn(); - if(replace || followup) - $('.' + type + '-update').html(Number(obj[type].count)); - else - $('.' + type + '-update').html(Number(obj[type].count) + Number($('.' + type + '-update').html())); + if(replace || followup) { + $('.' + type + '-update').html(count >= 100 ? '99+' : count); + } + else { + count = count + Number($('.' + type + '-update').html().replace(/\++$/, '')); + $('.' + type + '-update').html(count >= 100 ? '99+' : count); + } } else { $('.' + type + '-update').html('0'); -- cgit v1.2.3