aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-11-30 10:36:55 +0000
committerMario <mario@mariovavti.com>2022-11-30 10:36:55 +0000
commitbaf1b8b02de4ef3d62a2fd9126cbc05de1bf8711 (patch)
treeb8077a9755f2e2c23cc05d315c6a9bbc36e35ccd /Zotlabs/Widget
parent3ce1373ae0e5355b9d10eab5f5b8078245c4b8b6 (diff)
downloadvolse-hubzilla-baf1b8b02de4ef3d62a2fd9126cbc05de1bf8711.tar.gz
volse-hubzilla-baf1b8b02de4ef3d62a2fd9126cbc05de1bf8711.tar.bz2
volse-hubzilla-baf1b8b02de4ef3d62a2fd9126cbc05de1bf8711.zip
fetch the unseen count in a subquery instead of a separate query and rename array key
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r--Zotlabs/Widget/Messages.php18
1 files changed, 6 insertions, 12 deletions
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php
index c40d294e8..414353d8a 100644
--- a/Zotlabs/Widget/Messages.php
+++ b/Zotlabs/Widget/Messages.php
@@ -35,7 +35,7 @@ class Messages {
'notice_messages_title' => t('Notices'),
'loading' => t('Loading'),
'empty' => t('No messages'),
- 'unseen' => t('Unseen')
+ 'unseen_count' => t('Unseen')
]
]);
@@ -88,7 +88,9 @@ class Messages {
$type_sql = ' AND item_private IN (0, 1) ';
}
- $items = q("SELECT * FROM item WHERE uid = %d
+ $items = q("SELECT item.*, parent AS this_parent,
+ (SELECT count(*) FROM item WHERE uid = %d AND parent = this_parent AND item_unseen = 1 AND item_thread_top = 0 $vnotify_sql) AS unseen_count
+ FROM item WHERE uid = %d
AND created <= '%s'
$type_sql
AND item_thread_top = 1
@@ -96,6 +98,7 @@ class Messages {
ORDER BY created DESC $dummy_order_sql
LIMIT $limit OFFSET $offset",
intval(local_channel()),
+ intval(local_channel()),
dbescdate($loadtime)
);
@@ -158,15 +161,6 @@ class Messages {
$icon = '';
}
- $unseen = q("SELECT count(id) AS total FROM item WHERE uid = %d
- AND parent = %d
- AND item_thread_top = 0
- AND item_unseen = 1
- $vnotify_sql",
- intval(local_channel()),
- intval($item['id'])
- );
-
$entries[$i]['author_name'] = $item['author']['xchan_name'];
$entries[$i]['author_addr'] = (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']);
$entries[$i]['info'] = $info;
@@ -175,7 +169,7 @@ class Messages {
$entries[$i]['b64mid'] = gen_link_id($item['mid']);
$entries[$i]['href'] = z_root() . '/hq/' . gen_link_id($item['mid']);
$entries[$i]['icon'] = $icon;
- $entries[$i]['unseen'] = (($unseen[0]['total']) ? $unseen[0]['total'] : (($item['item_unseen']) ? '&#8192;' : ''));
+ $entries[$i]['unseen_count'] = (($item['unseen_count']) ? $item['unseen_count'] : (($item['item_unseen']) ? '&#8192;' : ''));
$entries[$i]['unseen_class'] = (($item['item_unseen']) ? 'primary' : 'secondary');
$i++;