aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Widget/Messages.php18
-rw-r--r--view/tpl/messages_widget.tpl6
2 files changed, 9 insertions, 15 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++;
diff --git a/view/tpl/messages_widget.tpl b/view/tpl/messages_widget.tpl
index 495f93ef7..ee933b392 100644
--- a/view/tpl/messages_widget.tpl
+++ b/view/tpl/messages_widget.tpl
@@ -53,8 +53,8 @@
<div class="text-break">{{$e.summary}}</div>
</div>
<small>{{$e.info}}</small>
- {{if $e.unseen}}
- <span class="badge bg-transparent border border-{{$e.unseen_class}} text-{{$e.unseen_class}} rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen}}">{{$e.unseen}}</span>
+ {{if $e.unseen_count}}
+ <span class="badge bg-transparent border border-{{$e.unseen_class}} text-{{$e.unseen_class}} rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen_count}}">{{$e.unseen_count}}</span>
{{/if}}
</a>
{{/foreach}}
@@ -129,7 +129,7 @@
e.author_addr,
e.href,
e.icon,
- e.unseen ? '<span class="badge bg-transparent border border-' + e.unseen_class + ' text-' + e.unseen_class + ' rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen}}">' + e.unseen + '</span>' : ''
+ e.unseen_count ? '<span class="badge bg-transparent border border-' + e.unseen_class + ' text-' + e.unseen_class + ' rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen_count}}">' + e.unseen_count + '</span>' : ''
);
$('#messages-loading').before(html);
});