aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Widget')
-rw-r--r--Zotlabs/Widget/Messages.php40
1 files changed, 17 insertions, 23 deletions
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php
index 2ba1f4da5..0f57a8d85 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')
]
]);
@@ -58,7 +58,7 @@ class Messages {
}
$channel = App::get_channel();
- $item_normal = item_normal();
+ $item_normal = str_replace('item.', 'i.', item_normal());
$entries = [];
$limit = 30;
$dummy_order_sql = '';
@@ -68,34 +68,37 @@ class Messages {
$vnotify_sql = '';
if (!($vnotify & VNOTIFY_LIKE)) {
- $vnotify_sql = " AND verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') ";
+ $vnotify_sql = " AND c.verb NOT IN ('" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') ";
}
elseif (!feature_enabled(local_channel(), 'dislike')) {
- $vnotify_sql = " AND verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') ";
+ $vnotify_sql = " AND c.verb NOT IN ('" . dbesc(ACTIVITY_DISLIKE) . "') ";
}
switch($type) {
case 'direct':
- $type_sql = ' AND item_private = 2 ';
+ $type_sql = ' AND i.item_private = 2 ';
// $dummy_order_sql has no other meaning but to trick
// some mysql backends into using the right index.
- $dummy_order_sql = ', received DESC ';
+ $dummy_order_sql = ', i.received DESC ';
break;
case 'starred':
- $type_sql = ' AND item_starred = 1 ';
+ $type_sql = ' AND i.item_starred = 1 ';
break;
default:
- $type_sql = ' AND item_private IN (0, 1) ';
+ $type_sql = ' AND i.item_private IN (0, 1) ';
}
- $items = q("SELECT * FROM item WHERE uid = %d
- AND created <= '%s'
+ $items = q("SELECT *,
+ (SELECT count(*) FROM item c WHERE c.uid = %d AND c.parent = i.parent AND c.item_unseen = 1 AND c.item_thread_top = 0 $vnotify_sql) AS unseen_count
+ FROM item i WHERE i.uid = %d
+ AND i.created <= '%s'
$type_sql
- AND item_thread_top = 1
+ AND i.item_thread_top = 1
$item_normal
- ORDER BY created DESC $dummy_order_sql
+ ORDER BY i.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,8 +169,8 @@ 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_class'] = (($item['item_unseen']) ? 'bg-primary' : 'bg-secondary');
+ $entries[$i]['unseen_count'] = (($item['unseen_count']) ? $item['unseen_count'] : (($item['item_unseen']) ? '&#8192;' : ''));
+ $entries[$i]['unseen_class'] = (($item['item_unseen']) ? 'primary' : 'secondary');
$i++;
}