aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-11-15 21:22:10 +0000
committerMario <mario@mariovavti.com>2022-11-15 21:22:10 +0000
commitc392a77b46958555bc16592fe4d57e9ab0b7e126 (patch)
treebcb9767aa34814c9199ed42e899e1174d1543afd
parent08c2c9bc22b5cffc21e8f7d7ea1cda30c2e1af93 (diff)
downloadvolse-hubzilla-c392a77b46958555bc16592fe4d57e9ab0b7e126.tar.gz
volse-hubzilla-c392a77b46958555bc16592fe4d57e9ab0b7e126.tar.bz2
volse-hubzilla-c392a77b46958555bc16592fe4d57e9ab0b7e126.zip
performance: just count the first 99 unseen items and display 99+ if there are more than 99
-rw-r--r--Zotlabs/Module/Sse_bs.php24
-rw-r--r--view/tpl/notifications_widget.tpl14
2 files changed, 22 insertions, 16 deletions
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 3a4e4e09e..4aabcafcb 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -205,18 +205,18 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
+ $r = q("SELECT id FROM item
WHERE uid = %d and item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1)
AND obj_type NOT IN ('Document', 'Video', 'Audio', 'Image')
AND author_xchan != '%s'
$item_normal
- $sql_extra",
+ $sql_extra LIMIT 100",
intval(self::$uid),
dbesc(self::$ob_hash)
);
if($r)
- $result['network']['count'] = intval($r[0]['total']);
+ $result['network']['count'] = count($r);
return $result;
}
@@ -285,17 +285,17 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
+ $r = q("SELECT id FROM item
WHERE uid = %d and item_unseen = 1 AND item_private = 2
$item_normal
$sql_extra
- AND author_xchan != '%s'",
+ AND author_xchan != '%s' LIMIT 100",
intval(self::$uid),
dbesc(self::$ob_hash)
);
if($r)
- $result['dm']['count'] = intval($r[0]['total']);
+ $result['dm']['count'] = count($r);
return $result;
}
@@ -365,17 +365,17 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
+ $r = q("SELECT id FROM item
WHERE uid = %d and item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1)
$item_normal
$sql_extra
- AND author_xchan != '%s'",
+ AND author_xchan != '%s' LIMIT 100",
intval(self::$uid),
dbesc(self::$ob_hash)
);
if($r)
- $result['home']['count'] = intval($r[0]['total']);
+ $result['home']['count'] = count($r);
return $result;
}
@@ -458,19 +458,19 @@ class Sse_bs extends Controller {
}
- $r = q("SELECT count(id) as total FROM item
+ $r = q("SELECT id FROM item
WHERE uid = %d AND item_unseen = 1
AND created > '%s'
$item_normal
$sql_extra
- AND author_xchan != '%s'",
+ AND author_xchan != '%s' LIMIT 100",
intval($sys['channel_id']),
dbescdate($_SESSION['static_loadtime']),
dbesc(self::$ob_hash)
);
if($r)
- $result['pubs']['count'] = intval($r[0]['total']);
+ $result['pubs']['count'] = count($r);
return $result;
}
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');