aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Widget/Messages.php14
-rw-r--r--view/js/main.js6
-rw-r--r--view/tpl/messages_widget.tpl7
3 files changed, 22 insertions, 5 deletions
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php
index 38c822502..199bd8665 100644
--- a/Zotlabs/Widget/Messages.php
+++ b/Zotlabs/Widget/Messages.php
@@ -34,7 +34,8 @@ class Messages {
'starred_messages_title' => t('Starred messages'),
'notice_messages_title' => t('Notices'),
'loading' => t('Loading'),
- 'empty' => t('No messages')
+ 'empty' => t('No messages'),
+ 'unseen' => t('Unseen')
]
]);
@@ -147,14 +148,23 @@ 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",
+ 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_url'];
+ $entries[$i]['author_addr'] = (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']);
$entries[$i]['info'] = $info;
$entries[$i]['created'] = datetime_convert('UTC', date_default_timezone_get(), $item['created']);
$entries[$i]['summary'] = $summary;
$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']) ? ' ' : ''));
$i++;
}
diff --git a/view/js/main.js b/view/js/main.js
index aff6eab4d..c409eed35 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -197,8 +197,7 @@ $(document).ready(function() {
if (singlethread_modules.indexOf(module) !== -1) {
history.pushState(stateObj, '', module + '/' + b64mid);
- $('.message').removeClass('active');
- $('[data-b64mid="' + b64mid + '"].message').addClass('active');
+
}
if (b64mid) {
@@ -207,6 +206,9 @@ $(document).ready(function() {
if(! page_load) {
prepareLiveUpdate(b64mid, notify_id);
+ $('.message').removeClass('active');
+ $('[data-b64mid="' + b64mid + '"].message').addClass('active');
+ $('[data-b64mid="' + b64mid + '"].message .badge').remove();
}
}
}
diff --git a/view/tpl/messages_widget.tpl b/view/tpl/messages_widget.tpl
index ddb21beb5..90f8e13c7 100644
--- a/view/tpl/messages_widget.tpl
+++ b/view/tpl/messages_widget.tpl
@@ -36,6 +36,7 @@
<div class="text-break">{2}</div>
</div>
<small>{3}</small>
+ {8}
</a>
</div>
<div id="dm-container" class="list-group list-group-flush" data-offset="10">
@@ -52,6 +53,9 @@
<div class="text-break">{{$e.summary}}</div>
</div>
<small>{{$e.info}}</small>
+ {{if $e.unseen}}
+ <span class="badge bg-primary rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen}}">{{$e.unseen}}</span>
+ {{/if}}
</a>
{{/foreach}}
<div id="messages-empty" class="list-group-item border-0"{{if $entries}} style="display: none;"{{/if}}>
@@ -124,7 +128,8 @@
e.author_name,
e.author_addr,
e.href,
- e.icon
+ e.icon,
+ e.unseen ? '<span class="badge bg-primary rounded-pill position-absolute bottom-0 end-0 m-2" title="{{$strings.unseen}}">' + e.unseen + '</span>' : ''
);
$('#messages-loading').before(html);
});